pavex/request/
request_head.rs

1use http::{HeaderMap, Method, Uri, Version};
2
3#[derive(Debug)]
4/// All the information that is transmitted as part of an HTTP request ahead of the body.
5///
6/// It includes the [method](Method), the [target](Uri),
7/// the [HTTP version](Version), and the [headers](HeaderMap).
8///
9/// # Guide
10///
11/// Check out [the guide](https://pavex.dev/docs/guide/request_data/wire_data/)
12/// for a thorough introduction to `RequestHead`.
13pub struct RequestHead {
14    /// The HTTP method of the request.
15    pub method: Method,
16    /// The [target](https://datatracker.ietf.org/doc/html/rfc7230#section-5.3) of the request.
17    pub target: Uri,
18    /// The HTTP version used by the request.
19    pub version: Version,
20    /// The headers attached to the request.
21    pub headers: HeaderMap,
22}
23
24impl From<http::request::Parts> for RequestHead {
25    fn from(parts: http::request::Parts) -> Self {
26        Self {
27            method: parts.method,
28            target: parts.uri,
29            version: parts.version,
30            headers: parts.headers,
31        }
32    }
33}