From 0c27bea135ac91f2876e02db9894b6e8d5aad3c6 Mon Sep 17 00:00:00 2001 From: tamo Date: Tue, 16 Mar 2021 13:38:43 +0100 Subject: [PATCH] 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()