From 28d30354e7d05ff57f86fc53d7f58cc1350888d7 Mon Sep 17 00:00:00 2001 From: Vika Date: Sun, 5 Dec 2021 23:00:22 +0300 Subject: Debug JSON renderer for posts Because sometimes seeing the problem is better than searching for it. --- src/frontend/mod.rs | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'src/frontend/mod.rs') 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(mut req: Request>) -> 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") -- cgit 1.4.1