//! Helpers that look for the `rehydrate=true` query parameter so callers can opt in to cache warming.
use actix_web::HttpRequest;

/// Returns `true` when `?rehydrate=true` is present so upstream services can refresh caches.
///
/// # Parameters
///
/// - `req`: Incoming HTTP request whose query string is scanned.
///
/// # Returns
///
/// - `bool`: `true` when the query string contains `rehydrate=true`, otherwise `false`.
///
/// # Example
///
/// ```rust,no_run
/// # use actix_web::test::TestRequest;
/// # use actix_web::HttpRequest;
/// # use athena_rs::api::cache::rehydrate::check_rehydrate;
/// # async fn doc_example() {
/// let req = TestRequest::default().uri("/something?rehydrate=true").to_http_request();
/// assert!(check_rehydrate(&req).await);
/// # }
/// ```
pub async fn check_rehydrate(req: &HttpRequest) -> bool {
    req.query_string().split('&').any(|q| q == "rehydrate=true")
}
