middleware

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Sep 12, 2026 License: MIT Imports: 24 Imported by: 0

Documentation

Index

Constants

View Source
const (
	CSPHeader           = "Content-Security-Policy"
	CSPReportOnlyHeader = "Content-Security-Policy-Report-Only"
	NoncePlaceholder    = "{nonce}"
)
View Source
const (
	CacheStatusHeader = "X-Cache"
	CacheHit          = "HIT"
	CacheMiss         = "MISS"
)
View Source
const MinCompressSize = 1024
View Source
const RequestIDHeader = "X-Request-Id"

Variables

This section is empty.

Functions

func NonceFrom

func NonceFrom(ctx context.Context) string

func RequestID

func RequestID(next http.Handler) http.Handler

func RequestIDFrom

func RequestIDFrom(ctx context.Context) string

func StripTrailingSlash

func StripTrailingSlash(next http.Handler) http.Handler

func TrustedRequestID

func TrustedRequestID(next http.Handler) http.Handler

Types

type KeyFunc

type KeyFunc func(*http.Request) string

func ClientIP

func ClientIP(trustedProxies int) KeyFunc

type Middleware

type Middleware = router.Middleware

func AllowedHosts

func AllowedHosts(hosts []string, debug bool) Middleware

func CORS

func CORS(policy settings.CORS) Middleware

func CSP

func CSP(policy string, reportOnly bool) Middleware

func CSRF

func CSRF(manager *session.Manager, exempt []string) Middleware

func Compress

func Compress(level int) Middleware

func HSTS

func HSTS(maxAge time.Duration, trustedProxies int) Middleware

func LimitBody

func LimitBody(maxBytes int64) Middleware

func PageCache

func PageCache(c cache.Cache, policy settings.PageCache, sessionCookie string) Middleware

func RateLimit

func RateLimit(policy settings.RateLimit, trustedProxies int) Middleware

func RateLimitBy

func RateLimitBy(policy settings.RateLimit, key KeyFunc) Middleware

func Recoverer

func Recoverer(logger *slog.Logger) Middleware

func RequestLogger

func RequestLogger(logger *slog.Logger) Middleware

func RequireHTTPS

func RequireHTTPS(trustedProxies int) Middleware

func SecureHeaders

func SecureHeaders(policy settings.Security) Middleware

Jump to

Keyboard shortcuts

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