Documentation
¶
Overview ¶
Package ratelimit provides a rate limiting functionality.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func NewMiddleware ¶
func NewMiddleware(c *Config) (m proxy.Middleware)
NewMiddleware returns middleware with rate limiting functionality. c must be valid.
Types ¶
type Config ¶
type Config struct {
// Logger is used for logging in the ratelimit middleware. It must not be
// nil.
Logger *slog.Logger
// AllowlistAddrs is a slice of IP addresses excluded from rate limiting.
AllowlistAddrs netutil.SliceSubnetSet
// Ratelimit is a maximum number of requests per second from a given IP. It
// must be positive.
Ratelimit uint
// SubnetLenIPv4 is a subnet length for IPv4 addresses used for rate
// limiting requests.
SubnetLenIPv4 uint
// SubnetLenIPv6 is a subnet length for IPv6 addresses used for rate
// limiting requests.
SubnetLenIPv6 uint
}
Config is the configuration for the ratelimit middleware.
func (*Config) Validate ¶
Validate implements the validate.Interface interface for *Config.
Click to show internal directories.
Click to hide internal directories.