middleware

package
v0.0.0-...-d686f0b Latest Latest
Warning

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

Go to latest
Published: Oct 26, 2025 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CORSMiddleware

func CORSMiddleware(config CORSConfig) gin.HandlerFunc

CORSMiddleware creates a middleware that handles CORS

func LoggingMiddleware

func LoggingMiddleware(store storage.LogStorage) gin.HandlerFunc

LoggingMiddleware creates a middleware that logs all HTTP requests

func PerRouteRateLimitMiddleware

func PerRouteRateLimitMiddleware(prl *PerRouteRateLimiter) gin.HandlerFunc

PerRouteRateLimitMiddleware creates a middleware that enforces per-route rate limiting

func RateLimitMiddleware

func RateLimitMiddleware(limiter *RateLimiter) gin.HandlerFunc

RateLimitMiddleware creates a middleware that enforces rate limiting

func RecoveryMiddleware

func RecoveryMiddleware() gin.HandlerFunc

RecoveryMiddleware creates a middleware that recovers from panics

Types

type CORSConfig

type CORSConfig struct {
	AllowedOrigins []string
	AllowedMethods []string
	AllowedHeaders []string
}

CORSConfig holds CORS configuration

type PerRouteRateLimiter

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

PerRouteRateLimiter manages rate limiters for individual routes

func NewPerRouteRateLimiter

func NewPerRouteRateLimiter() *PerRouteRateLimiter

NewPerRouteRateLimiter creates a new per-route rate limiter

func (*PerRouteRateLimiter) AddRoute

func (prl *PerRouteRateLimiter) AddRoute(path string, requestsPerSecond int, burst int)

AddRoute adds a rate limiter for a specific route

type RateLimiter

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

RateLimiter manages rate limiting for the gateway

func NewRateLimiter

func NewRateLimiter(requestsPerSecond int, burst int) *RateLimiter

NewRateLimiter creates a new rate limiter

Jump to

Keyboard shortcuts

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