Documentation
¶
Index ¶
- func HeadersFromContext(ctx context.Context) http.Header
- func NewErrorHandlingMiddleware() func(next wasabi.RequestHandler) wasabi.RequestHandler
- func NewHeadersMiddleware() func(next http.Handler) http.Handler
- func NewMetricsMiddleware(scope string, skip func(wasabi.Request) bool) func(next wasabi.RequestHandler) wasabi.RequestHandler
- func NewQueryParamsMiddleware() func(next http.Handler) http.Handler
- func QueryParamsFromContext(ctx context.Context) url.Values
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func HeadersFromContext ¶
HeadersFromContext retrieves HTTP headers from the given context. It takes a single parameter ctx of type context.Context. It returns an http.Header containing the headers if present in the context, or nil if the context is nil or does not contain headers.
func NewErrorHandlingMiddleware ¶ added in v0.3.0
func NewErrorHandlingMiddleware() func(next wasabi.RequestHandler) wasabi.RequestHandler
NewErrorHandlingMiddleware creates a middleware that handles errors and panics during request handling. It takes no parameters and returns a function that wraps a wasabi.RequestHandler. The returned function logs any errors or panics that occur during the handling of a request.
func NewHeadersMiddleware ¶
NewHeadersMiddleware creates a middleware that injects request headers into the request context. It returns a function that takes an http.Handler and returns an http.Handler. This middleware allows subsequent handlers to access the request headers from the context.
func NewMetricsMiddleware ¶ added in v0.3.0
func NewMetricsMiddleware(scope string, skip func(wasabi.Request) bool) func(next wasabi.RequestHandler) wasabi.RequestHandler
NewMetricsMiddleware creates a middleware that records request duration metrics. It takes a scope of type string and returns a function that wraps a wasabi.RequestHandler. It returns a wasabi.RequestHandler that records the duration of each request and logs whether an error occurred. It panics if there is an error initializing the metric.
func NewQueryParamsMiddleware ¶
NewQueryParamsMiddleware creates a middleware that extracts query parameters from the URL and stores them in the request context. It returns a function that takes an http.Handler and returns an http.Handler. This middleware allows subsequent handlers to access query parameters via the request context.
func QueryParamsFromContext ¶
QueryParamsFromContext retrieves URL query parameters from the given context. It takes a single parameter ctx of type context.Context. It returns url.Values containing the query parameters if present, or nil if the context is nil or does not contain query parameters.
Types ¶
This section is empty.