diff options
| author | tv <tv@krebsco.de> | 2026-10-31 05:29:49 +0100 |
|---|---|---|
| committer | tv <tv@krebsco.de> | 2026-10-31 05:29:49 +0100 |
| commit | ca0bd76db94e5d561f5c30b7b211e865d9e9e494 (patch) | |
| tree | 74ef8413967a9ccb7dc042854d88d79bcae67aa4 /src/api/mod.rs | |
| parent | c76fd5b9b0a3bba6c8ffa847e5fc818661e800d6 (diff) | |
api: unify media-type stripping
Diffstat (limited to 'src/api/mod.rs')
| -rw-r--r-- | src/api/mod.rs | 6 |
1 files changed, 6 insertions, 0 deletions
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() +} |
