From ca0bd76db94e5d561f5c30b7b211e865d9e9e494 Mon Sep 17 00:00:00 2001 From: tv Date: Sat, 31 Oct 2026 05:29:49 +0100 Subject: api: unify media-type stripping --- src/api/stats/prometheus.rs | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'src/api/stats/prometheus.rs') diff --git a/src/api/stats/prometheus.rs b/src/api/stats/prometheus.rs index 0b770bd..8f7538f 100644 --- a/src/api/stats/prometheus.rs +++ b/src/api/stats/prometheus.rs @@ -5,6 +5,7 @@ use std::fmt::Write; use super::StatsResponse; +use crate::api::media_type; use crate::api::peers::{PeerListResponse, PeerLivenessStatus}; use crate::state::Incidents; use crate::transport::Destination; @@ -17,10 +18,10 @@ pub(super) const CONTENT_TYPE: &str = "text/plain; version=0.0.4; charset=utf-8" /// plain text; browsers and curl don't name either. pub(super) fn wanted(accept: Option<&str>) -> bool { accept.is_some_and(|accept| { - accept.split(',').any(|item| { - let media = item.split(';').next().unwrap_or("").trim(); - media == "application/openmetrics-text" || media == "text/plain" - }) + accept + .split(',') + .map(media_type) + .any(|media| media == "application/openmetrics-text" || media == "text/plain") }) } -- cgit v1.3.1