mirror of
https://git.alemi.dev/http-debugger.git
synced 2024-11-23 16:04:48 +01:00
feat: return pretty json in responses
This commit is contained in:
parent
c7c3cc2815
commit
1d0223a407
2 changed files with 5 additions and 4 deletions
|
@ -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
|
||||
|
|
|
@ -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]
|
||||
|
|
Loading…
Reference in a new issue