set json header, get rid of redundant host output in bail message

main
Charlotte Som 2024-11-27 08:30:17 +02:00
parent 4b79a621fb
commit e9f9e35c9d
2 changed files with 8 additions and 4 deletions

View File

@ -455,7 +455,7 @@ pub async fn index_server(server: Arc<RelayServer>, host: String) -> Result<()>
{ {
let mut active_indexers = server.active_indexers.lock().await; let mut active_indexers = server.active_indexers.lock().await;
if active_indexers.contains(&host) { if active_indexers.contains(&host) {
bail!("Indexer already running for host {}", &host); bail!("Indexer already running for host");
} }
active_indexers.insert(host.clone()); active_indexers.insert(host.clone());

View File

@ -21,7 +21,10 @@ pub async fn handle_request_crawl(
Ok(input) => input, Ok(input) => input,
Err(_) => { Err(_) => {
// TODO: surely we can build out an XRPC abstraction or something // TODO: surely we can build out an XRPC abstraction or something
return Ok(Response::builder().status(400).body(body_full( return Ok(Response::builder()
.status(400)
.header("Content-Type", "application/json")
.body(body_full(
r#"{"error":"InvalidRequest","message":"Failed to parse request body"}"#, r#"{"error":"InvalidRequest","message":"Failed to parse request body"}"#,
))?); ))?);
} }
@ -36,5 +39,6 @@ pub async fn handle_request_crawl(
Ok(Response::builder() Ok(Response::builder()
.status(200) .status(200)
.header("Content-Type", "application/json")
.body(body_full(r#"{"status":"ok"}"#))?) .body(body_full(r#"{"status":"ok"}"#))?)
} }