diff options
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") |