Documentation
¶
Overview ¶
Package middleware implements useful HTTP middleware for routers compatible with the standard library mux.
Index ¶
- Constants
- func CORS(origin string) func(http.Handler) http.Handler
- func Logger(l *slog.Logger) func(http.Handler) http.Handler
- func Recoverer(next http.Handler, fn http.HandlerFunc) http.Handler
- func RequestID(next http.Handler) http.Handler
- func RequestLogger(next http.Handler) http.Handler
- func RequestSize(bytes int64) func(http.Handler) http.Handler
Constants ¶
View Source
const RequestIDHeader = "X-Request-ID"
RequestIDHeader is the key used for request IDs.
Variables ¶
This section is empty.
Functions ¶
func Logger ¶
Logger adds the given *slog.Logger to a request's context.Context.
func Recoverer ¶
Recoverer recovers from any panics in the request chain, logs the recover value and executes the given response handler.
func RequestLogger ¶
RequestLogger logs any incoming requests to the debug level if a *slog.Logger is present in the request's context.Context.
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.