middleware

package
v0.0.0-...-4cdf813 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AdminAuth

func AdminAuth(cfg config.AdminAuthConfig) gin.HandlerFunc

AdminAuth returns a middleware that authenticates admin requests. If auth is disabled in config, it passes all requests through. Supports both Basic Auth and Bearer Token authentication.

func GetRequestID

func GetRequestID(c *gin.Context) string

GetRequestID returns the request_id set by RequestID middleware (if present).

func Recovery

func Recovery() gin.HandlerFunc

Recovery creates a recovery middleware with structured logging

func RequestID

func RequestID() gin.HandlerFunc

RequestID ensures every request has an X-Request-ID header and stores it in gin.Context.

func RequestLogger

func RequestLogger() gin.HandlerFunc

RequestLogger creates a structured logging middleware for Gin

func ResponseCache

func ResponseCache(cacheManager *cache.CacheManager, config CacheConfig) gin.HandlerFunc

ResponseCache creates a middleware that caches HTTP responses

Types

type CacheConfig

type CacheConfig struct {
	TTL         time.Duration
	KeyPrefix   string
	SkipPaths   []string
	OnlyMethods []string
}

CacheConfig holds cache middleware configuration

type CachedResponse

type CachedResponse struct {
	StatusCode  int               `json:"status_code"`
	Headers     map[string]string `json:"headers"`
	Body        []byte            `json:"body"`
	ContentType string            `json:"content_type"`
	CachedAt    time.Time         `json:"cached_at"`
}

CachedResponse represents a cached HTTP response

Jump to

Keyboard shortcuts

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