Documentation ¶
Index ¶
- func Chain(f http.Handler, mm ...Func) http.Handler
- type Func
- func NewAuth(auth auth.Authenticator) Func
- func NewCaching(rc *cache.RouteCache) Func
- func NewCompression(deflateLevel int, ignoreRoutes ...string) Func
- func NewInjectObservability() Func
- func NewLoggingTracing(path string, statusCodeLogger StatusCodeLoggerHandler) Func
- func NewRateLimiting(limiter *rate.Limiter) Func
- func NewRecovery() Func
- func NewRequestObserver(method, path string) Func
- type StatusCodeLoggerHandler
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Func ¶
Func type declaration of middleware func.
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 ¶
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 ¶
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 ¶
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)