faucet-stream 0.1.4

A declarative, config-driven REST API client with pluggable authentication, pagination, and JSONPath extraction
Documentation
1
2
3
4
5
6
7
8
9
10
11
//! Bearer token authentication.

use crate::error::FaucetError;
use reqwest::header::{HeaderMap, HeaderValue};

pub fn apply(headers: &mut HeaderMap, token: &str) -> Result<(), FaucetError> {
    let val = HeaderValue::from_str(&format!("Bearer {token}"))
        .map_err(|e| FaucetError::Auth(format!("invalid bearer token value: {e}")))?;
    headers.insert("Authorization", val);
    Ok(())
}