middleware

package
v0.0.0-...-dc0472d Latest Latest
Warning

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

Go to latest
Published: Feb 22, 2026 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// RequestIdentifier is the header name for request ID.
	RequestIdentifier = "X-Request-ID"
)
View Source
const (
	// SlowRequestThreshold defines when to capture flight recorder traces.
	SlowRequestThreshold = 500 * time.Millisecond
)

Variables

View Source
var AllowedQueryParams = map[string]map[string]bool{
	http.MethodGet + "/ecommerce/v1/orders":        GetOrdersListReqParams,
	http.MethodPost + "/ecommerce/v1/orders":       nil,
	http.MethodGet + "/ecommerce/v1/orders/:id":    nil,
	http.MethodDelete + "/ecommerce/v1/orders/:id": nil,
}
View Source
var GetOrdersListReqParams = map[string]bool{
	"limit": true,
	"page":  true,
}

Functions

func AuthMiddleware

func AuthMiddleware() gin.HandlerFunc

func HasUnSupportedQueryParams

func HasUnSupportedQueryParams(req *http.Request, supportedParams map[string]bool) bool

func InternalAuthMiddleware

func InternalAuthMiddleware() gin.HandlerFunc

func QueryParamsCheckMiddleware

func QueryParamsCheckMiddleware(lgr logger.Logger) gin.HandlerFunc

QueryParamsCheckMiddleware - Middleware to check for unsupported query parameters.

func ReqIDMiddleware

func ReqIDMiddleware() gin.HandlerFunc

ReqIDMiddleware injects a request ID into the context and response header, creates one if it is not present already.

func RequestLogMiddleware

func RequestLogMiddleware(lgr logger.Logger, fr *flightrecorder.Recorder) gin.HandlerFunc

func ResponseHeadersMiddleware

func ResponseHeadersMiddleware() gin.HandlerFunc

Types

type ContextKey

type ContextKey string

ContextKey is a type for context keys.

Jump to

Keyboard shortcuts

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