Documentation
¶
Index ¶
- Constants
- func NonceFrom(ctx context.Context) string
- func RequestID(next http.Handler) http.Handler
- func RequestIDFrom(ctx context.Context) string
- func StripTrailingSlash(next http.Handler) http.Handler
- func TrustedRequestID(next http.Handler) http.Handler
- type KeyFunc
- type Middleware
- func AllowedHosts(hosts []string, debug bool) Middleware
- func CORS(policy settings.CORS) Middleware
- func CSP(policy string, reportOnly bool) Middleware
- func CSRF(manager *session.Manager, exempt []string) Middleware
- func Compress(level int) Middleware
- func HSTS(maxAge time.Duration, trustedProxies int) Middleware
- func LimitBody(maxBytes int64) Middleware
- func PageCache(c cache.Cache, policy settings.PageCache, sessionCookie string) Middleware
- func RateLimit(policy settings.RateLimit, trustedProxies int) Middleware
- func RateLimitBy(policy settings.RateLimit, key KeyFunc) Middleware
- func Recoverer(logger *slog.Logger) Middleware
- func RequestLogger(logger *slog.Logger) Middleware
- func RequireHTTPS(trustedProxies int) Middleware
- func SecureHeaders(policy settings.Security) Middleware
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 RequestIDFrom ¶
Types ¶
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 Compress ¶
func Compress(level int) Middleware
func LimitBody ¶
func LimitBody(maxBytes int64) 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
Click to show internal directories.
Click to hide internal directories.