From 0c27bea135ac91f2876e02db9894b6e8d5aad3c6 Mon Sep 17 00:00:00 2001 From: tamo Date: Tue, 16 Mar 2021 13:38:43 +0100 Subject: [PATCH 1/2] return a 400 on / when meilisearch is running in production --- meilisearch-http/src/lib.rs | 1 + meilisearch-http/src/routes/mod.rs | 13 +++++++++++++ 2 files changed, 14 insertions(+) diff --git a/meilisearch-http/src/lib.rs b/meilisearch-http/src/lib.rs index b5f35f277..12a2f85a8 100644 --- a/meilisearch-http/src/lib.rs +++ b/meilisearch-http/src/lib.rs @@ -63,6 +63,7 @@ pub fn create_app( .service(routes::load_css) } else { app + .service(routes::running) } } diff --git a/meilisearch-http/src/routes/mod.rs b/meilisearch-http/src/routes/mod.rs index 15a858055..b22056bdf 100644 --- a/meilisearch-http/src/routes/mod.rs +++ b/meilisearch-http/src/routes/mod.rs @@ -29,6 +29,7 @@ impl IndexUpdateResponse { } } +/// Return the dashboard, should not be used in production. See [running] #[get("/")] pub async fn load_html() -> HttpResponse { HttpResponse::Ok() @@ -36,6 +37,18 @@ pub async fn load_html() -> HttpResponse { .body(include_str!("../../public/interface.html").to_string()) } +/// Always return a 200 with: +/// ```json +/// { +/// "status": "Meilisearch is running" +/// } +/// ``` +#[get("/")] +pub async fn running() -> HttpResponse { + let payload = serde_json::json!({ "status": "MeiliSearch is running" }).to_string(); + HttpResponse::Ok().body(payload) +} + #[get("/bulma.min.css")] pub async fn load_css() -> HttpResponse { HttpResponse::Ok() From 81255814b1c4440c41d7f6313693d3ef1a51de54 Mon Sep 17 00:00:00 2001 From: Irevoire Date: Tue, 16 Mar 2021 16:57:29 +0100 Subject: [PATCH 2/2] Update meilisearch-http/src/routes/mod.rs Co-authored-by: marin --- meilisearch-http/src/routes/mod.rs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/meilisearch-http/src/routes/mod.rs b/meilisearch-http/src/routes/mod.rs index b22056bdf..e2aeb8171 100644 --- a/meilisearch-http/src/routes/mod.rs +++ b/meilisearch-http/src/routes/mod.rs @@ -45,8 +45,7 @@ pub async fn load_html() -> HttpResponse { /// ``` #[get("/")] pub async fn running() -> HttpResponse { - let payload = serde_json::json!({ "status": "MeiliSearch is running" }).to_string(); - HttpResponse::Ok().body(payload) + HttpResponse::Ok().json(serde_json::json!({ "status": "MeiliSearch is running" })) } #[get("/bulma.min.css")]