middleware

package
v0.73.2 Latest Latest
Warning

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

Go to latest
Published: Oct 14, 2022 License: Apache-2.0 Imports: 26 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Chain

func Chain(f http.Handler, mm ...Func) http.Handler

Chain chains middlewares to a handler func.

Types

type Func

type Func func(next http.Handler) http.Handler

Func type declaration of middleware func.

func NewAppNameVersion added in v0.72.0

func NewAppNameVersion(name, version string) Func

NewAppNameVersion adds an app name header and an app version header to all responses. Existing values of these headers are overwritten.

func NewAuth

func NewAuth(auth auth.Authenticator) Func

NewAuth creates a Func that implements authentication using an Authenticator.

func NewCaching

func NewCaching(rc *cache.RouteCache) Func

NewCaching creates a cache layer as a middleware when used as part of a middleware chain any middleware later in the chain, will not be executed, but the headers it appends will be part of the cache.

func NewCompression

func NewCompression(deflateLevel int, ignoreRoutes ...string) Func

NewCompression initializes a compression middleware. As per Section 3.5 of the HTTP/1.1 RFC, GZIP and Deflate compression methods are supported. https://tools.ietf.org/html/rfc2616#section-14.3

func NewInjectObservability

func NewInjectObservability() Func

NewInjectObservability injects a correlation ID unless one is already present.

func NewLoggingTracing

func NewLoggingTracing(path string, statusCodeLogger StatusCodeLoggerHandler) Func

NewLoggingTracing creates a Func that continues a tracing span and finishes it. It uses Jaeger and OpenTracing and will also log the HTTP request on debug level if configured so.

func NewRateLimiting

func NewRateLimiting(limiter *rate.Limiter) Func

NewRateLimiting creates a Func that adds a rate limit to a route.

func NewRecovery

func NewRecovery() Func

NewRecovery creates a Func that ensures recovery and no panic.

func NewRequestObserver

func NewRequestObserver(method, path string) Func

NewRequestObserver creates a Func that captures status code and duration metrics about the responses returned; metrics are exposed via Prometheus. This middleware is enabled by default.

type StatusCodeLoggerHandler

type StatusCodeLoggerHandler struct {
	// contains filtered or unexported fields
}

func NewStatusCodeLoggerHandler

func NewStatusCodeLoggerHandler(cfg string) (StatusCodeLoggerHandler, error)

Jump to

Keyboard shortcuts

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