middleware

package
v0.10.1 Latest Latest
Warning

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

Go to latest
Published: Sep 9, 2026 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Authenticate

func Authenticate(logger *slog.Logger, authenticators ...auth.Authenticator) func(http.Handler) http.Handler

Authenticate requires browser authentication and redirects unauthenticated users to login.

func AuthenticateAPI

func AuthenticateAPI(logger *slog.Logger, authenticators ...auth.Authenticator) func(http.Handler) http.Handler

AuthenticateAPI requires API authentication and returns JSON for unauthenticated requests.

func Chain

func Chain(handler http.Handler, middlewares ...Middleware) http.Handler

Chain wraps a handler with middleware in declaration order.

Types

type Middleware

type Middleware func(http.Handler) http.Handler

Middleware wraps an HTTP handler with cross-cutting behavior.

func AccessLog

func AccessLog(logger *slog.Logger) Middleware

AccessLog records request method, path, and elapsed time after handling.

func RecoverPanics

func RecoverPanics(logger *slog.Logger) Middleware

RecoverPanics converts handler panics into logged internal server errors.

func RejectCrossSiteWrites

func RejectCrossSiteWrites(logger *slog.Logger) Middleware

RejectCrossSiteWrites blocks and logs cross-site state-changing browser requests.

func RequestContext added in v0.8.0

func RequestContext() Middleware

RequestContext supplies diagnostics even when access logging is disabled.

func RequireRole

func RequireRole(roles ...string) Middleware

RequireRole authorizes an authenticated request against one of the allowed roles.

func SecurityHeaders

func SecurityHeaders() Middleware

SecurityHeaders adds Lore security response headers.

Jump to

Keyboard shortcuts

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