Skip to main content

HeaderMapView

Trait HeaderMapView 

Source
pub trait HeaderMapView {
    // Required method
    fn get_all_ci(&self, name: &str) -> Vec<&str>;
}
Expand description

Framework-agnostic header map interface.

Implement this trait for your HTTP framework’s header type to use ash_extract_headers(). The implementation must support case-insensitive lookup and returning all values for a given header name.

§Example (test helper)

use ash_core::headers::HeaderMapView;

struct SimpleHeaders(Vec<(String, String)>);

impl HeaderMapView for SimpleHeaders {
    fn get_all_ci(&self, name: &str) -> Vec<&str> {
        let name_lower = name.to_ascii_lowercase();
        self.0.iter()
            .filter(|(k, _)| k.to_ascii_lowercase() == name_lower)
            .map(|(_, v)| v.as_str())
            .collect()
    }
}

Required Methods§

Source

fn get_all_ci(&self, name: &str) -> Vec<&str>

Return all values for the given header name (case-insensitive).

Must return an empty Vec if the header is not present. Must return multiple entries if the header appears multiple times.

Implementors§