Documentation
¶
Index ¶
- func RequestLogger(logger *slog.Logger, logLevel slog.Level, formatter RequestLogFormatter) func(http.Handler) http.Handler
- func WithInflightMetrics(m *metrics.InflightMetrics) func(next http.Handler) http.Handler
- func WithRequestMetrics(m metrics.RequestMetrics) func(next http.Handler) http.Handler
- type RequestLogFormatter
- type RequestLogFormatterFunc
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func RequestLogger ¶
func RequestLogger(logger *slog.Logger, logLevel slog.Level, formatter RequestLogFormatter) func(http.Handler) http.Handler
RequestLogger logs incoming HTTP requests.
func WithInflightMetrics ¶
func WithRequestMetrics ¶
Types ¶
type RequestLogFormatter ¶
A RequestLogFormatter takes the HTTP request, the resulting HTTP status code and latency and formats the log entry.
var DefaultRequestLogFormatter RequestLogFormatter = &defaultRequestLogFormatter{}
DefaultRequestLogFormatter is the default RequestLogFormatter. It logs the request's HTTP method and the path, the response's status code and the latency of the request.
type RequestLogFormatterFunc ¶
type RequestLogFormatterFunc func(r *http.Request, statusCode int, latency time.Duration) []slog.Attr
The RequestLogFormatterFunc type is an adapter that allows an ordinary function to be used as a RequestLogFormatter.
func (RequestLogFormatterFunc) FormatRequest ¶
func (f RequestLogFormatterFunc) FormatRequest(r *http.Request, statusCode int, latency time.Duration) []slog.Attr
FormatRequest calls f(r, statusCode, latency)
Click to show internal directories.
Click to hide internal directories.