pub struct RateLimitMiddleware { /* private fields */ }Expand description
Request policies with atomic rolling or fixed-window storage.
Each allowed request extends the current window until its quota is exhausted.
Expired buckets are removed through an ordered expiry index. Both indexes
are bounded by max_buckets; no per-request timestamp list is retained.
Independent processes can install shared database/cache storage.
Implementations§
Source§impl RateLimitMiddleware
impl RateLimitMiddleware
pub fn new(config: RateLimitConfig) -> Self
Sourcepub fn with_base_path(self, path: impl Into<String>) -> Self
pub fn with_base_path(self, path: impl Into<String>) -> Self
Match and key routes relative to the application’s auth mount path.
pub fn with_plugin_rules(self, rules: Vec<PluginRateLimit>) -> Self
Trait Implementations§
Source§impl Debug for RateLimitMiddleware
impl Debug for RateLimitMiddleware
Source§impl Middleware for RateLimitMiddleware
impl Middleware for RateLimitMiddleware
Source§fn before_request<'life0, 'life1, 'async_trait>(
&'life0 self,
req: &'life1 AuthRequest,
) -> Pin<Box<dyn Future<Output = AuthResult<Option<AuthResponse>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn before_request<'life0, 'life1, 'async_trait>(
&'life0 self,
req: &'life1 AuthRequest,
) -> Pin<Box<dyn Future<Output = AuthResult<Option<AuthResponse>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Called before the request is dispatched to plugins. Read more
Source§fn after_request<'life0, 'life1, 'async_trait>(
&'life0 self,
_req: &'life1 AuthRequest,
response: AuthResponse,
) -> Pin<Box<dyn Future<Output = AuthResult<AuthResponse>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn after_request<'life0, 'life1, 'async_trait>(
&'life0 self,
_req: &'life1 AuthRequest,
response: AuthResponse,
) -> Pin<Box<dyn Future<Output = AuthResult<AuthResponse>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Called after a response has been produced. Read more
Auto Trait Implementations§
impl !Freeze for RateLimitMiddleware
impl !RefUnwindSafe for RateLimitMiddleware
impl !UnwindSafe for RateLimitMiddleware
impl Send for RateLimitMiddleware
impl Sync for RateLimitMiddleware
impl Unpin for RateLimitMiddleware
impl UnsafeUnpin for RateLimitMiddleware
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more