Documentation
¶
Index ¶
- func Authenticate(logger *slog.Logger, authenticators ...auth.Authenticator) func(http.Handler) http.Handler
- func AuthenticateAPI(logger *slog.Logger, authenticators ...auth.Authenticator) func(http.Handler) http.Handler
- func Chain(handler http.Handler, middlewares ...Middleware) http.Handler
- type Middleware
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.
Types ¶
type Middleware ¶
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.