//! Retrieves the `X-Athena-Client` header that selects the Supabase/Postgres client.
use crate::api::headers::request_context::resolved_athena_client;
use actix_web::HttpRequest;

/// Returns the header value used to decide which downstream client should handle the request.
pub fn x_athena_client(req: &HttpRequest) -> String {
    if let Some(client_name) = resolved_athena_client(req) {
        return client_name;
    }

    req.headers()
        .get("X-Athena-Client")
        .and_then(|h| h.to_str().ok())
        .map(str::trim)
        .unwrap_or("")
        .to_string()
}
