Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func NewRateLimiter ¶
func NewRateLimiter(key func(httpx.Context) string, createLimiter func(httpx.Context) (*rate.Limiter, time.Duration), options ...Option) httpx.Middleware
NewRateLimiter creates a new rate limiting middleware with customizable key extraction and limiter creation. It uses caching to store rate limiters per key and singleflight to prevent cache stampedes.
Types ¶
type Option ¶
type Option func(*options)
Option is a functional option for configuring the rate limiter middleware.
func WithCache ¶
WithCache sets a custom cache implementation for storing rate limiters. The default cache is an in-memory cache.
func WithSetTTL ¶
WithSetTTL sets the timeout for cache set operations. This prevents hanging when the cache backend is unresponsive.
Click to show internal directories.
Click to hide internal directories.