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 | f72c751c837a41b807fe09cebe79e78a31309def (patch) | |
| tree | 8d2fbdd4cc5ce90043bb91213d637c043e190676 /src/api/mod.rs | |
| parent | 9c45cb3e478a519182a7d9bf48af1529b2ccc457 (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() +} |
