mirror of
https://git.alemi.dev/http-debugger.git
synced 2024-11-21 23:14:49 +01:00
feat: return time as float
This commit is contained in:
parent
67019e1743
commit
c7c3cc2815
2 changed files with 3 additions and 3 deletions
|
@ -1,6 +1,6 @@
|
||||||
[package]
|
[package]
|
||||||
name = "http-debugger"
|
name = "http-debugger"
|
||||||
version = "0.2.1"
|
version = "0.2.2"
|
||||||
edition = "2021"
|
edition = "2021"
|
||||||
|
|
||||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||||
|
|
|
@ -63,7 +63,7 @@ struct InspectRequest {
|
||||||
#[serde(serialize_with = "ordered_map")]
|
#[serde(serialize_with = "ordered_map")]
|
||||||
pub headers: HashMap<String, Value>,
|
pub headers: HashMap<String, Value>,
|
||||||
pub body: Option<String>,
|
pub body: Option<String>,
|
||||||
pub time: u128,
|
pub time: f64,
|
||||||
}
|
}
|
||||||
|
|
||||||
async fn echo_json(mut req: Request<Body>) -> Result<Response<Body>, hyper::http::Error> {
|
async fn echo_json(mut req: Request<Body>) -> Result<Response<Body>, hyper::http::Error> {
|
||||||
|
@ -73,7 +73,7 @@ async fn echo_json(mut req: Request<Body>) -> Result<Response<Body>, hyper::http
|
||||||
version: format!("{:?}", req.version()),
|
version: format!("{:?}", req.version()),
|
||||||
headers: req.headers().iter().map(|(k, v)| parse_header(k, v)).filter(|(k, _v)| k != "host").collect(),
|
headers: req.headers().iter().map(|(k, v)| parse_header(k, v)).filter(|(k, _v)| k != "host").collect(),
|
||||||
body: String::from_utf8(body::to_bytes(req.body_mut()).await.unwrap().to_vec()).ok(),
|
body: String::from_utf8(body::to_bytes(req.body_mut()).await.unwrap().to_vec()).ok(),
|
||||||
time: SystemTime::now().duration_since(UNIX_EPOCH).unwrap_or(Duration::from_secs(0)).as_millis(),
|
time: SystemTime::now().duration_since(UNIX_EPOCH).unwrap_or(Duration::from_secs(0)).as_secs_f64(),
|
||||||
};
|
};
|
||||||
|
|
||||||
let serialized = serde_json::to_string(&inspect).unwrap_or("[]".to_string());
|
let serialized = serde_json::to_string(&inspect).unwrap_or("[]".to_string());
|
||||||
|
|
Loading…
Reference in a new issue