//! Retrieves the `X-Athena-Client` header that selects the logical Athena client.

use actix_web::HttpRequest;

use super::request_context::resolved_athena_client;

/// Returns the client name used to decide which downstream Athena client handles 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(|header| header.to_str().ok())
        .map(str::trim)
        .unwrap_or("")
        .to_string()
}
