diff options
author | Vika <vika@fireburn.ru> | 2021-12-05 23:00:22 +0300 |
---|---|---|
committer | Vika <vika@fireburn.ru> | 2021-12-05 23:00:22 +0300 |
commit | 28d30354e7d05ff57f86fc53d7f58cc1350888d7 (patch) | |
tree | 671eea5531afda325bb31b1b83c710a74702f020 /src/frontend/mod.rs | |
parent | 4aa7f01da39ab55b4f6346e7565d8bb29566de39 (diff) | |
download | kittybox-28d30354e7d05ff57f86fc53d7f58cc1350888d7.tar.zst |
Debug JSON renderer for posts
Because sometimes seeing the problem is better than searching for it.
Diffstat (limited to 'src/frontend/mod.rs')
-rw-r--r-- | src/frontend/mod.rs | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/src/frontend/mod.rs b/src/frontend/mod.rs index ce4f015..5426f7e 100644 --- a/src/frontend/mod.rs +++ b/src/frontend/mod.rs @@ -326,6 +326,18 @@ pub async fn render_post<S: Storage>(mut req: Request<ApplicationState<S>>) -> R let post = get_post_from_database(&req.state().storage, entry_url.as_str(), query.after, &user) .await?; + #[cfg(debug_assertions)] + if let Some(value) = req.header("Accept") { + log::debug!("{:?}", value); + + if value == "application/json" { + return Ok(Response::builder(200) + .content_type("application/json; charset=utf-8") + .body(post.to_string()) + .build()); + } + } + let template: String = match post["type"][0] .as_str() .expect("Empty type array or invalid type") |