server

package
v2.5.0 Latest Latest
Warning

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

Go to latest
Published: Nov 18, 2023 License: Apache-2.0 Imports: 11 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 an HTTP request header.
	ReadHeaderTimeout time.Duration = 60 * time.Second
)
View Source
const (
	// PatternMetricsHandler is the path pattern to use for the metrics handler.
	PatternMetricsHandler = "/metrics"
	// PatternRelayHandler is the path pattern to use for the relay handler.
	PatternRelayHandler = "/relay"
)
View Source
const (
	// QueryParamTarget is the request query parameter used for providing the relay target.
	QueryParamTarget = "target"
)
View Source
const (
	// ResponseHeaderTimeout is the maximum time to wait for reading an HTTP response header.
	ResponseHeaderTimeout = 60 * time.Second
)

Variables

View Source
var (
	// ErrMissingQueryParam is returned when a client request is missing a query parameter.
	ErrMissingQueryParam = errors.New("missing query parameter")
)

Errors used by the server package.

Functions

func Error added in v2.5.0

func Error(w http.ResponseWriter, r *http.Request, err string, code int)

Error replies to the request with the specified error message and HTTP code. It also logs the request remote address, error and code as a warning.

func NewServeMux added in v2.5.0

func NewServeMux() *http.ServeMux

NewServeMux creates a top-level request multiplexer for the application.

func RelayHandler

func RelayHandler() http.Handler

RelayHandler is an http.Handler for target relay requests.

func Run added in v2.5.0

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

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

Types

This section is empty.

Jump to

Keyboard shortcuts

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