set no cache header for metrics
This commit is contained in:
parent
a0c3a13383
commit
e463c4dd90
|
@ -342,6 +342,6 @@ fn cache_header(secs: u64) -> TypedHeader<CacheControl> {
|
|||
)
|
||||
}
|
||||
|
||||
fn no_cache_header() -> TypedHeader<CacheControl> {
|
||||
pub fn no_cache_header() -> TypedHeader<CacheControl> {
|
||||
TypedHeader(CacheControl::new().with_no_cache())
|
||||
}
|
||||
|
|
|
@ -29,6 +29,8 @@ use tower_http::{
|
|||
};
|
||||
use tracing::{debug, info};
|
||||
|
||||
use self::handlers::no_cache_header;
|
||||
|
||||
pub async fn run(app: App, mut shutdown_rx: ShutdownRx, bot_tx: Sender<BotMessage>) {
|
||||
aide::gen::on_error(|error| {
|
||||
panic!("Could not generate docs: {error}");
|
||||
|
@ -170,11 +172,12 @@ pub fn parse_listen_addr(addr: &str) -> Result<SocketAddr, AddrParseError> {
|
|||
}
|
||||
}
|
||||
|
||||
async fn metrics() -> String {
|
||||
async fn metrics() -> impl IntoApiResponse {
|
||||
let metric_families = prometheus::gather();
|
||||
|
||||
let encoder = TextEncoder::new();
|
||||
encoder.encode_to_string(&metric_families).unwrap()
|
||||
let metrics = encoder.encode_to_string(&metric_families).unwrap();
|
||||
(no_cache_header(), metrics)
|
||||
}
|
||||
async fn serve_openapi(Extension(api): Extension<Arc<OpenApi>>) -> impl IntoApiResponse {
|
||||
Json(api.as_ref()).into_response()
|
||||
|
|
Loading…
Reference in New Issue