cory 0.1.2

Visual Bitcoin transaction ancestry explorer with embedded web UI and REST API.
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
use axum::http::HeaderMap;

use super::error::AppError;

pub(super) fn check_auth(expected_token: &str, headers: &HeaderMap) -> Result<(), AppError> {
    let token = headers
        .get("x-api-token")
        .and_then(|v| v.to_str().ok())
        .unwrap_or("");

    if token != expected_token {
        return Err(AppError::Unauthorized(
            "invalid or missing X-API-Token".to_string(),
        ));
    }
    Ok(())
}