docspec-http 1.5.1

HTTP API server for DocSpec document conversion
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
//! Cache-Control middleware for all HTTP responses.

use axum::http::{header::CACHE_CONTROL, HeaderValue};
use tower_http::set_header::SetResponseHeaderLayer;

use crate::format::CACHE_CONTROL_VALUE;

/// Returns a middleware layer that adds [`CACHE_CONTROL_VALUE`] to every
/// response, overriding any existing Cache-Control header.
///
/// This prevents intermediate proxies and clients from caching conversion results
/// or health check responses.
#[inline]
pub fn cache_control_layer() -> SetResponseHeaderLayer<HeaderValue> {
    SetResponseHeaderLayer::overriding(CACHE_CONTROL, HeaderValue::from_static(CACHE_CONTROL_VALUE))
}