server

package
v1.0.1-0...-c468f24 Latest Latest
Warning

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

Go to latest
Published: Jul 2, 2023 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// ShutdownTimeout is the maximum time to wait for the HTTP server to shutdown.
	ShutdownTimeout time.Duration = 30 * time.Second
	// ReadHeaderTimeout is the maximum time to wait for reading read an HTTP request header.
	ReadHeaderTimeout time.Duration = 60 * time.Second
)
View Source
const (
	// MetricsHandlerPattern is the path pattern to use for the metrics handler.
	MetricsHandlerPattern = "/metrics"
	// RelayHandlerPattern is the path pattern to use for the relay handler.
	RelayHandlerPattern = "/relay"
)

Variables

This section is empty.

Functions

func ListenAndServe

func ListenAndServe(ctx context.Context, addr string, handler http.Handler) error

ListenAndServe listens on the TCP network address addr and serves the handler. This function implements graceful shutdown when the passed ctx is done.

func NewRouter

func NewRouter() http.Handler

NewRouter creates a top-level http.Handler router for the application.

func NewTargetContext

func NewTargetContext(ctx context.Context, t *url.URL) context.Context

NewTargetContext returns a new Context that carries value t.

func RelayHandler

func RelayHandler() http.Handler

RelayHandler is an http.Handler for target relay requests.

func RelayRequestTimer

func RelayRequestTimer(next http.Handler) http.Handler

RelayRequestTimer is a middleware to measure relay request durations.

func RelayTargetExtractor

func RelayTargetExtractor(next http.Handler) http.Handler

RelayTargetExtractor is a middleware for extracting a 'target' query parameter from the request. The extracted value (if any) is parsed as a *url.URL object. If the parameter is missing or invalid, the middleware returns a bad request error to the client.

func TargetFromContext

func TargetFromContext(ctx context.Context) (*url.URL, bool)

TargetFromContext returns the target value stored in ctx, if any.

Types

This section is empty.

Jump to

Keyboard shortcuts

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