feat: return pretty json in responses

This commit is contained in:
əlemi 2022-10-21 02:48:24 +02:00
parent c7c3cc2815
commit 1d0223a407
2 changed files with 5 additions and 4 deletions

View file

@ -1,6 +1,6 @@
[package]
name = "http-debugger"
version = "0.2.2"
version = "0.2.3"
edition = "2021"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

View file

@ -76,15 +76,16 @@ async fn echo_json(mut req: Request<Body>) -> Result<Response<Body>, hyper::http
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_mini = serde_json::to_string(&inspect).unwrap_or("[]".to_string());
let serialized_pretty = serde_json::to_string_pretty(&inspect).unwrap_or("[]".to_string());
// println!(" * {}", serde_json::to_string_pretty(&response)?);
println!(" * {}", serialized);
println!(" * {}", serialized_mini);
Response::builder()
.status(StatusCode::OK)
.header("Content-Type", "application/json")
.body(serialized.into())
.body(serialized_pretty.into())
}
#[tokio::main]