middlewares

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Feb 15, 2026 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const (
	HeaderTraceID       = "X-Trace-Id"
	HeaderCorrelationID = "X-Correlation-Id"
	HeaderRequestID     = "X-Request-Id"
)

Header names for trace and correlation IDs (configurable via options if needed)

Variables

This section is empty.

Functions

func AuthMiddleware

func AuthMiddleware() gin.HandlerFunc

AuthMiddleware validates JWT token from Authorization header

func CORS

func CORS() gin.HandlerFunc

func LoggerMiddleware added in v0.1.7

func LoggerMiddleware() gin.HandlerFunc

LoggerMiddleware logs HTTP request details including method, path, status code, latency, and client IP

func NoMethodHandler

func NoMethodHandler() gin.HandlerFunc

func NoRouteHandler

func NoRouteHandler() gin.HandlerFunc

func RateLimiter added in v0.1.7

func RateLimiter() gin.HandlerFunc

RateLimiter returns a rate limiting middleware

func RecoveryHandler

func RecoveryHandler(ctx *gin.Context)

func TraceMiddleware added in v0.1.11

func TraceMiddleware() gin.HandlerFunc

TraceMiddleware injects trace_id and correlation_id into the request context so they appear in structured logs. It reads X-Trace-Id and X-Correlation-Id from incoming headers, or X-Request-Id as fallback for trace ID. If no trace ID is provided, one is generated. Downstream handlers and the logger middleware can use the request context to get these values.

Types

This section is empty.

Jump to

Keyboard shortcuts

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