pub struct RateLimitSection {
pub enabled: bool,
pub requests_per_second: f64,
pub burst_size: u32,
pub max_tracked_ips: usize,
pub trust_proxy: bool,
pub trusted_proxies: Vec<String>,
}Expand description
Per-IP rate limiting (token bucket).
Fields§
§enabled: boolEnable rate-limit middleware. Default: false (enable in Production appsettings).
requests_per_second: f64Sustained requests per second per client IP.
burst_size: u32Burst capacity before throttling.
max_tracked_ips: usizeMaximum distinct client IPs tracked (LRU eviction when exceeded).
trust_proxy: boolTrust X-Forwarded-For / X-Real-IP headers for client IP extraction. Only enable when behind a trusted reverse proxy. Default: false.
trusted_proxies: Vec<String>CIDR ranges of the trusted proxies. When TrustProxy is enabled, the
forwarded headers are only consulted if the direct peer address belongs
to one of these ranges; the client IP is then the right-most address in
X-Forwarded-For that is not itself a trusted proxy.
An empty list with TrustProxy = true is treated as “trust nothing”:
the headers are ignored (a client can otherwise rotate
X-Forwarded-For to bypass the limiter).
Trait Implementations§
Source§impl Clone for RateLimitSection
impl Clone for RateLimitSection
Source§fn clone(&self) -> RateLimitSection
fn clone(&self) -> RateLimitSection
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more