middleware

package
v0.74.0 Latest Latest
Warning

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

Go to latest
Published: Jan 28, 2025 License: Apache-2.0 Imports: 21 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, error)

NewAppNameVersion adds an app method header and an app path 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, error)

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, error)

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, error)

NewLoggingTracing creates a Func that continues a tracing span and finishes it.

func NewRateLimiting

func NewRateLimiting(limiter *rate.Limiter) (Func, error)

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.

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