Documentation ¶
Index ¶
- Constants
- func ListenAndServe(ctx context.Context, addr string, handler http.Handler) error
- func NewRouter() http.Handler
- func NewTargetContext(ctx context.Context, t *url.URL) context.Context
- func RelayHandler() http.Handler
- func RelayRequestTimer(next http.Handler) http.Handler
- func RelayTargetExtractor(next http.Handler) http.Handler
- func TargetFromContext(ctx context.Context) (*url.URL, bool)
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 ¶
ListenAndServe listens on the TCP network address addr and serves the handler. This function implements graceful shutdown when the passed ctx is done.
func NewTargetContext ¶
NewTargetContext returns a new Context that carries value t.
func RelayHandler ¶
RelayHandler is an http.Handler for target relay requests.
func RelayRequestTimer ¶
RelayRequestTimer is a middleware to measure relay request durations.
func RelayTargetExtractor ¶
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.
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.