Documentation ¶
Index ¶
- func Logger(l *slog.Logger, extensions ...LogExtension) func(http.Handler) http.Handler
- func LoggerFrom(ctx context.Context) *slog.Logger
- func MethodLog(r *http.Request) (slog.Attr, bool)
- func RequestID(next http.Handler) http.Handler
- func RequestIDFrom(ctx context.Context) string
- func RequestIDLog(r *http.Request) (slog.Attr, bool)
- func WithLogger(ctx context.Context, logger *slog.Logger) context.Context
- func WithRequestID(ctx context.Context, id string) context.Context
- type LogExtension
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Logger ¶
Logger middleware injects logger into each request context Logger is configured slog.Logger with additions of LogExtension.
func LoggerFrom ¶
LoggerFrom gets a logger from the context.
func RequestID ¶
RequestID middleware injects request id for each request. It searches for X-Request-ID header in request, if not present, generates a new one.
func RequestIDFrom ¶
RequestIDFrom extracts request id from context. Returns empty string if request id can not be found.
func RequestIDLog ¶
RequestIDLog logger extension for log request id.
func WithLogger ¶
WithLogger injects logger in the context.
Types ¶
Click to show internal directories.
Click to hide internal directories.