pub struct TrustedProxyIpKeyExtractor { /* private fields */ }Implementations§
Source§impl TrustedProxyIpKeyExtractor
impl TrustedProxyIpKeyExtractor
Sourcepub fn new(trusted_proxies: &[String]) -> Self
pub fn new(trusted_proxies: &[String]) -> Self
Builds an extractor from raw trusted proxy entries.
Entries may be CIDR ranges or single IP addresses. Invalid entries are
skipped by aster_forge_utils::net::parse_trusted_proxies after logging
a warning.
Sourcepub fn from_trusted(trusted: Vec<IpNet>) -> Self
pub fn from_trusted(trusted: Vec<IpNet>) -> Self
Builds an extractor from an already parsed trusted proxy list.
Sourcepub fn with_rejection_response<F>(self, factory: F) -> Self
pub fn with_rejection_response<F>(self, factory: F) -> Self
Uses a product-provided response factory when the request exceeds its quota.
The factory receives the retry delay in whole seconds and the response builder created by
actix-governor. Products can use this to preserve their response envelope and error code
without reimplementing trusted-proxy extraction.
Sourcepub fn is_trusted(&self, ip: IpAddr) -> bool
pub fn is_trusted(&self, ip: IpAddr) -> bool
Returns whether the provided IP is trusted as a proxy.
Trait Implementations§
Source§impl Clone for TrustedProxyIpKeyExtractor
impl Clone for TrustedProxyIpKeyExtractor
Source§fn clone(&self) -> TrustedProxyIpKeyExtractor
fn clone(&self) -> TrustedProxyIpKeyExtractor
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 TrustedProxyIpKeyExtractor
impl Debug for TrustedProxyIpKeyExtractor
Source§impl KeyExtractor for TrustedProxyIpKeyExtractor
impl KeyExtractor for TrustedProxyIpKeyExtractor
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 more§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.
Auto Trait Implementations§
impl Freeze for TrustedProxyIpKeyExtractor
impl !RefUnwindSafe for TrustedProxyIpKeyExtractor
impl Send for TrustedProxyIpKeyExtractor
impl Sync for TrustedProxyIpKeyExtractor
impl Unpin for TrustedProxyIpKeyExtractor
impl !UnwindSafe for TrustedProxyIpKeyExtractor
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