server

package
v2.6.6 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 13, 2024 License: Apache-2.0 Imports: 15 Imported by: 6

Documentation

Overview

Package server provides tools to create http servers and handlers wrapping the lura router

Index

Constants

View Source
const (
	// HeaderCompleteResponseValue is the value of the CompleteResponseHeader
	// if the response is complete
	HeaderCompleteResponseValue = "true"
	// HeaderIncompleteResponseValue is the value of the CompleteResponseHeader
	// if the response is not complete
	HeaderIncompleteResponseValue = "false"
)

Variables

View Source
var (
	// CompleteResponseHeaderName is the header to flag incomplete responses to the client
	CompleteResponseHeaderName = "X-Gateway-Completed"
	// HeadersToSend are the headers to pass from the router request to the proxy
	HeadersToSend = []string{"Content-Type"}
	// UserAgentHeaderValue is the value of the User-Agent header to add to the proxy request
	UserAgentHeaderValue = []string{core.KrakendUserAgent}

	// ErrInternalError is the error returned by the router when something went wrong
	ErrInternalError = errors.New("internal server error")
	// ErrPrivateKey is the error returned by the router when the private key is not defined
	ErrPrivateKey = errors.New("private key not defined")
	// ErrPublicKey is the error returned by the router when the public key is not defined
	ErrPublicKey = errors.New("public key not defined")
)

Functions

func DefaultToHTTPError

func DefaultToHTTPError(_ error) int

DefaultToHTTPError is a ToHTTPError transalator that always returns an internal server error

func InitHTTPDefaultTransport

func InitHTTPDefaultTransport(cfg config.ServiceConfig)

InitHTTPDefaultTransport ensures the default HTTP transport is configured just once per execution

func InitHTTPDefaultTransportWithLogger added in v2.1.0

func InitHTTPDefaultTransportWithLogger(cfg config.ServiceConfig, logger logging.Logger)

func NewServer

func NewServer(cfg config.ServiceConfig, handler http.Handler) *http.Server

NewServer returns a http.Server ready to serve the injected handler

func NewServerWithLogger added in v2.1.0

func NewServerWithLogger(cfg config.ServiceConfig, handler http.Handler, logger logging.Logger) *http.Server

func ParseClientTLSConfigWithLogger added in v2.1.0

func ParseClientTLSConfigWithLogger(cfg *config.ClientTLS, logger logging.Logger) *tls.Config

func ParseTLSConfig

func ParseTLSConfig(cfg *config.TLS) *tls.Config

ParseTLSConfig creates a tls.Config from the TLS section of the service configuration

func ParseTLSConfigWithLogger added in v2.1.0

func ParseTLSConfigWithLogger(cfg *config.TLS, logger logging.Logger) *tls.Config

func RunServer

func RunServer(ctx context.Context, cfg config.ServiceConfig, handler http.Handler) error

RunServer runs a http.Server with the given handler and configuration. It configures the TLS layer if required by the received configuration.

func RunServerWithLoggerFactory added in v2.1.0

func RunServerWithLoggerFactory(l logging.Logger) func(context.Context, config.ServiceConfig, http.Handler) error

Types

type ToHTTPError

type ToHTTPError func(error) int

ToHTTPError translates an error into a HTTP status code

Directories

Path Synopsis
Package plugin provides plugin register interfaces for building http handler plugins.
Package plugin provides plugin register interfaces for building http handler plugins.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL