//! Helpers around the `X-Publish-Event` header that toggles telemetry events.

use actix_web::HttpRequest;

/// Returns `true` when `X-Publish-Event` equals `true` (case-insensitive).
pub fn get_x_publish_event(req: &HttpRequest) -> bool {
    req.headers()
        .get("X-Publish-Event")
        .and_then(|header| header.to_str().ok())
        .map(|value| value.eq_ignore_ascii_case("true"))
        .unwrap_or(false)
}
