pub trait RequestParts: Send + Sync {
// Required methods
fn authorization_header(&self) -> Option<&str>;
fn get_header(&self, name: &str) -> Option<&str>;
fn method(&self) -> Option<&str>;
fn uri(&self) -> Option<&str>;
fn client_ip(&self) -> Option<IpAddr>;
// Provided method
fn bearer_token(&self) -> Option<&str> { ... }
}Expand description
Trait for extracting authentication-relevant data from requests
Required Methods§
Extract Authorization header as string
Sourcefn get_header(&self, name: &str) -> Option<&str>
fn get_header(&self, name: &str) -> Option<&str>
Get custom header value by name
Sourcefn client_ip(&self) -> Option<IpAddr>
fn client_ip(&self) -> Option<IpAddr>
The resolved client IP, None when nothing resolves (see
crate::client_ip::resolve_client_ip). This is what
crate::ip_allowlist::IpAllowlist::allows checks a restricted key’s request against;
None never satisfies a non-empty allowlist.
Provided Methods§
Sourcefn bearer_token(&self) -> Option<&str>
fn bearer_token(&self) -> Option<&str>
Extract Bearer token from Authorization header
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".