Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func InjectLogger ¶
InjectLogger returns middleware that stores logger in the request context. Downstream handlers retrieve it via logging.FromContext. Use this when you need context logger access without full request logging.
func RequestLogger ¶
func RequestLogger(logger *logging.Logger, opts ...RequestLoggerOption) func(http.Handler) http.Handler
RequestLogger returns middleware that injects a request-scoped logger into the context and logs each request on completion with method, path, status, and duration. Downstream handlers retrieve the logger via logging.FromContext.
Types ¶
type RequestLoggerOption ¶
type RequestLoggerOption func(*requestLoggerConfig)
RequestLoggerOption configures RequestLogger.
func WithIgnorePaths ¶
func WithIgnorePaths(paths ...string) RequestLoggerOption
WithIgnorePaths sets paths to skip logging entirely. A pattern ending in "*" matches by prefix (e.g. "/assets/*" matches "/assets/app.js"); any other pattern must match exactly (e.g. "/favicon.ico").
func WithRequestBodyLogging ¶
func WithRequestBodyLogging(maxBytes int64) RequestLoggerOption
WithRequestBodyLogging enables logging of the request body up to maxBytes. The body is restored so downstream handlers still receive it. Use only in development — request bodies often contain sensitive data.
func WithResponseBodyLogging ¶
func WithResponseBodyLogging(maxBytes int64) RequestLoggerOption
WithResponseBodyLogging enables logging of the response body up to maxBytes. Use only in development — response bodies can be large and may contain sensitive data.