pub struct RateLimitLayer;Expand description
Built-in middleware that enforces the process-wide rate limit
(configured via RWS_CONFIG_RATE_LIMIT_MAX_REQUESTS and
RWS_CONFIG_RATE_LIMIT_WINDOW_SECS).
Returns 429 Too Many Requests when the sliding-window budget for the
client IP is exhausted; otherwise passes the request to the next layer.
§Example
use rust_web_server::app::App;
use rust_web_server::middleware::{WithMiddleware, RateLimitLayer};
use rust_web_server::core::New;
let app = App::new().wrap(RateLimitLayer);Trait Implementations§
Source§impl Middleware for RateLimitLayer
impl Middleware for RateLimitLayer
fn handle( &self, request: &Request, connection: &ConnectionInfo, next: &dyn Application, ) -> Result<Response, String>
Auto Trait Implementations§
impl Freeze for RateLimitLayer
impl RefUnwindSafe for RateLimitLayer
impl Send for RateLimitLayer
impl Sync for RateLimitLayer
impl Unpin for RateLimitLayer
impl UnsafeUnpin for RateLimitLayer
impl UnwindSafe for RateLimitLayer
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