pub struct GlobalKeyExtractor;Expand description
A KeyExtractor that allow to do rate limiting for all incoming requests. This is useful if you want to hard-limit the HTTP load your app can handle.
Trait Implementations§
Source§impl Clone for GlobalKeyExtractor
impl Clone for GlobalKeyExtractor
Source§fn clone(&self) -> GlobalKeyExtractor
fn clone(&self) -> GlobalKeyExtractor
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for GlobalKeyExtractor
impl Debug for GlobalKeyExtractor
Source§impl KeyExtractor for GlobalKeyExtractor
impl KeyExtractor for GlobalKeyExtractor
Source§type KeyExtractionError = SimpleKeyExtractionError<&'static str>
type KeyExtractionError = SimpleKeyExtractionError<&'static str>
The type of the error that can occur if key extraction from the request fails.
Source§fn extract(
&self,
_req: &ServiceRequest,
) -> Result<Self::Key, Self::KeyExtractionError>
fn extract( &self, _req: &ServiceRequest, ) -> Result<Self::Key, Self::KeyExtractionError>
Extraction method, will return
KeyExtractionError response when the extract failedSource§fn exceed_rate_limit_response(
&self,
negative: &NotUntil<QuantaInstant>,
response: HttpResponseBuilder,
) -> HttpResponse
fn exceed_rate_limit_response( &self, negative: &NotUntil<QuantaInstant>, response: HttpResponseBuilder, ) -> HttpResponse
The content you want to show it when the rate limit is exceeded.
You can calculate the time at which a caller can expect the next positive rate-limiting result by using
NotUntil.
The HttpResponseBuilder allows you to build a fully customized HttpResponse in case of an error. Read moreSource§fn whitelisted_keys(&self) -> Vec<Self::Key>
fn whitelisted_keys(&self) -> Vec<Self::Key>
Returns a list of whitelisted keys. If a key is in this list, it will never be rate-limited.
Source§impl PartialEq for GlobalKeyExtractor
impl PartialEq for GlobalKeyExtractor
impl Copy for GlobalKeyExtractor
impl Eq for GlobalKeyExtractor
impl StructuralPartialEq for GlobalKeyExtractor
Auto Trait Implementations§
impl Freeze for GlobalKeyExtractor
impl RefUnwindSafe for GlobalKeyExtractor
impl Send for GlobalKeyExtractor
impl Sync for GlobalKeyExtractor
impl Unpin for GlobalKeyExtractor
impl UnwindSafe for GlobalKeyExtractor
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