middleware

package
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Mar 5, 2026 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BasicAuth

func BasicAuth(credential string) func(http.Handler) http.Handler

BasicAuth enforces HTTP basic auth when credential is configured as "user:pass".

func RateLimitByIP

func RateLimitByIP(rps float64, burst int, idleTTL time.Duration, exemptPathPrefixes ...string) func(http.Handler) http.Handler

RateLimitByIP applies token-bucket rate limiting keyed by client IP.

func RateLimitByIPWithConfig

func RateLimitByIPWithConfig(rps float64, burst int, cfg RateLimitByIPConfig) func(http.Handler) http.Handler

RateLimitByIPWithConfig applies token-bucket rate limiting keyed by client IP with bounded stale cleanup and optional client cardinality cap.

func Timeout

func Timeout(timeout time.Duration, exemptPathPrefixes ...string) func(http.Handler) http.Handler

Timeout enforces a request timeout for non-exempt paths.

Types

type RateLimitByIPConfig

type RateLimitByIPConfig struct {
	IdleTTL            time.Duration
	MaxClients         int
	CleanupBatch       int
	ExemptPathPrefixes []string
	TrustedProxyCIDRs  []string
}

RateLimitByIPConfig controls per-client limiter cache behavior.

Jump to

Keyboard shortcuts

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