ftnet_utils/
http.rs

1#[derive(serde::Serialize, serde::Deserialize, Debug, Clone)]
2pub struct Request {
3    pub uri: String,
4    pub method: String,
5    pub headers: Vec<(String, Vec<u8>)>,
6}
7
8impl From<hyper::http::request::Parts> for Request {
9    fn from(r: hyper::http::request::Parts) -> Self {
10        let mut headers = vec![];
11        for (k, v) in r.headers {
12            let k = match k {
13                Some(v) => v.to_string(),
14                None => continue,
15            };
16            headers.push((k, v.as_bytes().to_vec()));
17        }
18
19        Request {
20            uri: r.uri.to_string(),
21            method: r.method.to_string(),
22            headers,
23        }
24    }
25}
26
27#[derive(serde::Deserialize, serde::Serialize, Debug)]
28pub struct Response {
29    pub status: u16,
30    pub headers: Vec<(String, Vec<u8>)>,
31}
32
33pub type ProxyResponse =
34    hyper::Response<http_body_util::combinators::BoxBody<hyper::body::Bytes, hyper::Error>>;
35pub type ProxyResult = eyre::Result<ProxyResponse>;