structured-proxy 7.0.0

Universal gRPC→REST transcoding proxy — config-driven, works with any gRPC service
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
//! Request body media type.
//!
//! The body itself is read straight into the request message by
//! [`super::request::build_request_message`], as JSON or as a
//! `application/x-www-form-urlencoded` form.

use axum::http::HeaderMap;

/// Extract content type from headers (just the media type, no parameters).
pub fn content_type(headers: &HeaderMap) -> Option<&str> {
    headers
        .get("content-type")
        .and_then(|v| v.to_str().ok())
        .map(|ct| ct.split(';').next().unwrap_or(ct).trim())
}

#[cfg(test)]
mod tests;