handlers

package
v0.19.3 Latest Latest
Warning

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

Go to latest
Published: Apr 4, 2024 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewAuthenticationHandler added in v0.12.0

func NewAuthenticationHandler(authenticator rbac.Authenticator) func(http.Handler) http.Handler

NewAuthenticationHandler returns an http middleware that invokes the given authenticator and calls the next handler in the middleware chain, with the authenticated actor added to the request context.

If the authenticator returns an error, then the overall http request is failed with an Unauthorized code.

func PanicRecoveryHandler added in v0.17.0

func PanicRecoveryHandler(next http.Handler) http.Handler

PanicRecoveryHandler is a mux.MiddlewareFunc which recovers from any uncaught `panic`s further down the middleware chain.

If it recovers from a panic, it returns a 500 to the caller, and logs the route name along with the panicking error. name, as set by (mux.*Route).Name(), embeds it in the request context, and invokes the next middleware in the chain.

func TraceHandler

func TraceHandler(next http.Handler) http.Handler

TraceHandler is a mux.MiddlewareFunc which creates a span with the route's name, as set by (mux.*Route).Name(), embeds it in the request context, and invokes the next middleware in the chain.

It also annotates the span with the route_path_template, if it exists, and the route_uri. To add additional spans, extract the span in your VTAdminHTTPHandler like:

func Handler(ctx context.Context, r Request, api *API) *JSONResponse {
	span, _ := trace.FromContext(ctx)
	span.Annotate("foo", "bar")

	return NewJSONResponse(api.Something(ctx))
}

An unnamed route will get a span named "vtadmin:http:<unnamed route>".

Types

This section is empty.

Jump to

Keyboard shortcuts

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