Skip to main content

RequestParts

Trait RequestParts 

Source
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§

Source

fn authorization_header(&self) -> Option<&str>

Extract Authorization header as string

Source

fn get_header(&self, name: &str) -> Option<&str>

Get custom header value by name

Source

fn method(&self) -> Option<&str>

Get request method (if applicable)

Source

fn uri(&self) -> Option<&str>

Get request URI (if applicable)

Source

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§

Source

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".

Implementors§