Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Config ¶
type Config struct {
RequestsPerSecond float64 // Requests allowed per second
BurstSize int // Maximum burst size
CleanupInterval time.Duration // How often to clean up old entries
Enabled bool // Whether rate limiting is enabled
}
Config holds rate limiter configuration.
func DefaultConfig ¶
func DefaultConfig() *Config
DefaultConfig returns the default rate limiter configuration.
type Limiter ¶
type Limiter struct {
// contains filtered or unexported fields
}
Limiter implements a per-IP token bucket rate limiter.
func (*Limiter) Middleware ¶
Middleware returns an HTTP middleware that applies rate limiting.
func (*Limiter) RemainingTokens ¶
RemainingTokens returns the number of remaining tokens for a key.
func (*Limiter) ResetAfter ¶
ResetAfter returns the duration until the bucket is refilled.
Click to show internal directories.
Click to hide internal directories.