middleware

package
v0.0.0-...-48dfde4 Latest Latest
Warning

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

Go to latest
Published: Jun 9, 2025 License: GPL-3.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// AuthHeaderKey is the header key for API key authentication
	AuthHeaderKey = "X-API-Key"
)

Variables

This section is empty.

Functions

func APIKeyAuth

func APIKeyAuth(validAPIKey string) func(http.Handler) http.Handler

APIKeyAuth middleware checks for a valid API key in the request header

func LoggingMiddleware

func LoggingMiddleware() func(http.Handler) http.Handler

LoggingMiddleware logs information about each request

func RateLimit

func RateLimit(requestsPerSecond, burstSize float64) func(http.Handler) http.Handler

RateLimit middleware limits the number of requests per second per client

Types

type RateLimiter

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

RateLimiter implements a token bucket rate limiter

func NewRateLimiter

func NewRateLimiter(rate, bucketSize float64) *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