From e9f9e35c9d4283c4f6d766660bf415ccd7978eae Mon Sep 17 00:00:00 2001 From: Charlotte Som Date: Wed, 27 Nov 2024 08:30:17 +0200 Subject: [PATCH] set json header, get rid of redundant host output in bail message --- src/indexer.rs | 2 +- src/request_crawl.rs | 10 +++++++--- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/src/indexer.rs b/src/indexer.rs index 793c582..2675c22 100644 --- a/src/indexer.rs +++ b/src/indexer.rs @@ -455,7 +455,7 @@ pub async fn index_server(server: Arc, host: String) -> Result<()> { let mut active_indexers = server.active_indexers.lock().await; if active_indexers.contains(&host) { - bail!("Indexer already running for host {}", &host); + bail!("Indexer already running for host"); } active_indexers.insert(host.clone()); diff --git a/src/request_crawl.rs b/src/request_crawl.rs index 1ea2b2f..9215533 100644 --- a/src/request_crawl.rs +++ b/src/request_crawl.rs @@ -21,9 +21,12 @@ pub async fn handle_request_crawl( Ok(input) => input, Err(_) => { // TODO: surely we can build out an XRPC abstraction or something - return Ok(Response::builder().status(400).body(body_full( - r#"{"error":"InvalidRequest","message":"Failed to parse request body"}"#, - ))?); + return Ok(Response::builder() + .status(400) + .header("Content-Type", "application/json") + .body(body_full( + r#"{"error":"InvalidRequest","message":"Failed to parse request body"}"#, + ))?); } }; @@ -36,5 +39,6 @@ pub async fn handle_request_crawl( Ok(Response::builder() .status(200) + .header("Content-Type", "application/json") .body(body_full(r#"{"status":"ok"}"#))?) }