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 | 612d189f86a6d985db97ea23c5ce1bf72ac077a4 (patch) | |
| tree | 418b1675a81789fa24456a0bb7b940a8fad596e1 /src/api/mod.rs | |
| parent | 155c675dd5733b1887ee165689380c64134f173c (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() +} |
