Skip to main content

extract_header_api_key

Function extract_header_api_key 

Source
pub fn extract_header_api_key(
    headers: &HeaderMap,
) -> Result<Option<&str>, Error>
Expand description

Extract an API key from request fields.

X-API-Key takes precedence over Api-Key; the fallback is inspected only when X-API-Key is absent. If both are absent, this function returns None. The selected value is returned unchanged, so an empty field produces Some(""). A selected field that occurs more than once or is not text produces an error that does not contain its sensitive value. This function does not validate or authenticate the key, and callers must not log or echo it.