From 7ecefe37da9307c2e55a1ce3b177fe4f61dabb1d Mon Sep 17 00:00:00 2001 From: Irevoire Date: Fri, 19 Mar 2021 11:34:54 +0100 Subject: [PATCH] fix root route --- meilisearch-http/src/lib.rs | 2 +- meilisearch-http/src/routes/mod.rs | 12 ++++++++++++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/meilisearch-http/src/lib.rs b/meilisearch-http/src/lib.rs index cdd874a35..9532273aa 100644 --- a/meilisearch-http/src/lib.rs +++ b/meilisearch-http/src/lib.rs @@ -44,7 +44,7 @@ macro_rules! create_app { let app = if $enable_frontend { app.service(load_html).service(load_css) } else { - app + app.service(running) }; app.wrap( Cors::default() diff --git a/meilisearch-http/src/routes/mod.rs b/meilisearch-http/src/routes/mod.rs index e1345fa08..9164f2d2f 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,17 @@ 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 { + HttpResponse::Ok().json(serde_json::json!({ "status": "MeiliSearch is running" })) +} + #[get("/bulma.min.css")] pub async fn load_css() -> HttpResponse { HttpResponse::Ok()