middleware

package
v0.7.5 Latest Latest
Warning

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

Go to latest
Published: Aug 21, 2025 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

View Source
const (
	TraceIDKey   contextKey = "trace_id"
	UserIDKey    contextKey = "user_id"
	RequestIDKey contextKey = "request_id"
)

Variables

This section is empty.

Functions

func GetTraceIDFromContext added in v0.7.1

func GetTraceIDFromContext(ctx context.Context) string

GetTraceIDFromContext returns the trace id from the context

Types

type Middleware

type Middleware struct {
	// contains filtered or unexported fields
}

func New

func New(logger *slog.Logger) *Middleware

func (*Middleware) Chain

func (m *Middleware) Chain(middlewares ...MiddlewareFunc) MiddlewareFunc

Chain combines middlewares and returns a handler. Build chain from right to left

func (*Middleware) ExcludePaths added in v0.7.0

func (m *Middleware) ExcludePaths(paths ...string)

ExcludePaths excludes exact path matches Example: mw.ExcludePaths("/health")

func (*Middleware) ExcludePrefixes added in v0.7.0

func (m *Middleware) ExcludePrefixes(prefixes ...string)

ExcludePrefixes excludes paths starting with given prefixes Example: mw.ExcludePrefixes("/health/")

func (*Middleware) LogRequest

func (m *Middleware) LogRequest(next http.Handler) http.Handler

LogRequest logs HTTP requests with response details

func (*Middleware) RecoverPanic

func (m *Middleware) RecoverPanic(next http.Handler) http.Handler

RecoverPanic recovers from panics

func (*Middleware) ShouldSkip added in v0.7.0

func (m *Middleware) ShouldSkip(r *http.Request) bool

shouldSkip checks if request should skip middleware

type MiddlewareFunc added in v0.7.0

type MiddlewareFunc func(http.Handler) http.Handler

Directories

Path Synopsis
Package cors provides CORS (Cross-Origin Resource Sharing) middleware
Package cors provides CORS (Cross-Origin Resource Sharing) middleware
Package gzip provides gzip compression middleware
Package gzip provides gzip compression middleware

Jump to

Keyboard shortcuts

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