Skip to main content

structured_proxy/transcode/
body.rs

1//! Request body media type.
2//!
3//! The body itself is read straight into the request message by
4//! [`super::request::build_request_message`], as JSON or as a
5//! `application/x-www-form-urlencoded` form.
6
7use axum::http::HeaderMap;
8
9/// Extract content type from headers (just the media type, no parameters).
10pub fn content_type(headers: &HeaderMap) -> Option<&str> {
11    headers
12        .get("content-type")
13        .and_then(|v| v.to_str().ok())
14        .map(|ct| ct.split(';').next().unwrap_or(ct).trim())
15}
16
17#[cfg(test)]
18mod tests;