middleware

package
v0.5.0 Latest Latest
Warning

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

Go to latest
Published: Nov 11, 2026 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

View Source
const RequestIDContextKey requestIDContextKey = "request_id"
View Source
const RequestIDHeader = "X-Request-ID"

RequestID header key

Variables

This section is empty.

Functions

func ErrorHandler

func ErrorHandler(next http.Handler) http.Handler

ErrorHandler is an alias for Recovery for backward compatibility

func GetRequestID

func GetRequestID(ctx context.Context) string

GetRequestID retrieves request ID from context Checks both our context key and chi's context key

func Recovery

func Recovery(next http.Handler) http.Handler

Recovery middleware recovers from panics and logs them

func RequestID

func RequestID(next http.Handler) http.Handler

RequestID middleware adds a unique request ID to each request This works alongside chi's built-in RequestID middleware

func RequestMetrics

func RequestMetrics(next http.Handler) http.Handler

RequestMetrics middleware captures HTTP request metrics following Prometheus standards

Types

type ErrorDetail

type ErrorDetail struct {
	Code      string                 `json:"code"`
	Message   string                 `json:"message"`
	Details   map[string]interface{} `json:"details,omitempty"`
	RequestID string                 `json:"request_id,omitempty"`
}

type ErrorResponse

type ErrorResponse struct {
	Error ErrorDetail `json:"error"`
}

ErrorResponse structure per API standards

Jump to

Keyboard shortcuts

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