middleware

package
v0.0.0-...-439e5cb Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 17, 2026 License: MIT Imports: 9 Imported by: 0

Documentation

Overview

Package middleware provides HTTP handler useful decorators.

Index

Constants

This section is empty.

Variables

View Source
var AccessLevel slog.Level = slog.LevelError + 4

AccessLevel is the log level used for access logs.

Functions

func AccessLog

func AccessLog(next http.Handler, logger *slog.Logger, opts ...AccessLogOpts) http.Handler

AccessLog is a decorator/middleware that extracts/ads a correlation id from/to request/response.

func CorrelationID

func CorrelationID(next http.Handler, makeCorrelationID xtransport.CorrelationIDFactory) http.Handler

CorrelationID is a decorator/middleware that extracts/ads a correlation id from/to request/response.

func Recover

func Recover(next http.Handler, logger *slog.Logger) http.Handler

Recover is a decorator/middleware that gracefully logs any panic occurred while serving a request.

Types

type AccessLogOpts

type AccessLogOpts struct {
	// SkipMethods specifies the http methods to skip logging for.
	SkipMethods []string
	// ObfuscatePathValues specifies the request url parts that should be obscure.
	// Last maximum 8 chars from it will be replaced with "*".
	ObfuscatePathValues []string
}

AccessLogOpts holds some configuration for access log.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL