pub struct RateLimit { /* private fields */ }
Implementations§
source§impl RateLimit
impl RateLimit
sourcepub fn rate_limit(
&self,
headers: &HeaderMap,
addr: &SocketAddr
) -> Result<RateSnapshot, TooManyRequests>
pub fn rate_limit( &self, headers: &HeaderMap, addr: &SocketAddr ) -> Result<RateSnapshot, TooManyRequests>
Rate limit Request based on it’s HeaderMap state and given client SocketAddr “x-real-ip”, “x-forwarded-for” and “forwarded” headers are checked in order start from left to determine client’s socket address. Received SocketAddr will be used as fallback when all headers are absent or can’t provide valid client address.
Trait Implementations§
Auto Trait Implementations§
impl RefUnwindSafe for RateLimit
impl Send for RateLimit
impl Sync for RateLimit
impl Unpin for RateLimit
impl UnwindSafe for RateLimit
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