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/mod.rs | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'src/api/mod.rs') diff --git a/src/api/mod.rs b/src/api/mod.rs index 021bc52..fb860c7 100644 --- a/src/api/mod.rs +++ b/src/api/mod.rs @@ -209,3 +209,9 @@ pub(crate) fn store_status(error: StoreError, context: &str) -> ApiError { }; ApiError(status, Some(error.to_string())) } + +/// A media type without its parameters: `text/plain; charset=utf-8` is `text/plain`. +/// For `Content-Type`, and each item of an `Accept` (split at `,`). +pub(crate) fn media_type(value: &str) -> &str { + value.split(';').next().unwrap_or("").trim() +} -- cgit v1.3.1