middleware

package
v0.10.0 Latest Latest
Warning

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

Go to latest
Published: Jul 15, 2026 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const RequestIDHeader = "X-Request-ID"

Variables

This section is empty.

Functions

func CORS added in v0.2.0

func CORS(options CORSOptions) func(http.Handler) http.Handler

CORS returns a Middleware that handles Cross-Origin Resource Sharing.

func ContentLengthMiddleware added in v0.2.0

func ContentLengthMiddleware(next http.Handler) http.Handler

ContentLengthMiddleware automatically sets the Content-Length header

func GetRequestID added in v0.9.0

func GetRequestID(ctx context.Context) string

func Logger added in v0.9.0

func Logger(options ...LoggerOptions) func(http.Handler) http.Handler

func RealIP added in v0.9.0

func RealIP(next http.Handler) http.Handler

func RealIPWithOptions added in v0.9.0

func RealIPWithOptions(options RealIPOptions) func(http.Handler) http.Handler

func Recover added in v0.2.0

func Recover(next http.Handler) http.Handler

func RequestID added in v0.9.0

func RequestID(next http.Handler) http.Handler

func SecurityHeaders added in v0.9.0

func SecurityHeaders(options ...SecurityHeadersOptions) func(http.Handler) http.Handler

func Timeout added in v0.9.0

func Timeout(timeout time.Duration) func(http.Handler) http.Handler

func Timer

func Timer(next http.Handler) http.Handler

Types

type CORSOptions added in v0.2.0

type CORSOptions struct {
	AllowedOrigins   []string
	AllowedMethods   []string
	AllowedHeaders   []string
	ExposedHeaders   []string
	AllowCredentials bool
	MaxAge           int
}

type LoggerOptions added in v0.9.0

type LoggerOptions struct {
	Logger *log.Logger
}

type RealIPOptions added in v0.9.0

type RealIPOptions struct {
	TrustedProxies []string
}

type SecurityHeadersOptions added in v0.9.0

type SecurityHeadersOptions struct {
	ContentTypeOptions    string
	FrameOptions          string
	ReferrerPolicy        string
	ContentSecurityPolicy string
}

Jump to

Keyboard shortcuts

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