From a2ac2de0119c7a7b7ec89f73cfd749c39f3e2f01 Mon Sep 17 00:00:00 2001 From: tamo Date: Tue, 16 Mar 2021 11:17:54 +0100 Subject: [PATCH 1/4] Use 200 status code for healthcheck endpoint --- meilisearch-http/src/routes/health.rs | 2 +- meilisearch-http/tests/health.rs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/meilisearch-http/src/routes/health.rs b/meilisearch-http/src/routes/health.rs index c57e4c7e9..5544e2cea 100644 --- a/meilisearch-http/src/routes/health.rs +++ b/meilisearch-http/src/routes/health.rs @@ -9,5 +9,5 @@ pub fn services(cfg: &mut web::ServiceConfig) { #[get("/health")] async fn get_health() -> Result { - Ok(HttpResponse::NoContent().finish()) + Ok(HttpResponse::Ok().finish()) } diff --git a/meilisearch-http/tests/health.rs b/meilisearch-http/tests/health.rs index f72127431..57738e009 100644 --- a/meilisearch-http/tests/health.rs +++ b/meilisearch-http/tests/health.rs @@ -7,5 +7,5 @@ async fn test_healthyness() { // Check that the server is healthy let (_response, status_code) = server.get_health().await; - assert_eq!(status_code, 204); + assert_eq!(status_code, 200); } From f6d06899676dbb9e641f858ed8aff00ee91581de Mon Sep 17 00:00:00 2001 From: tamo Date: Tue, 16 Mar 2021 11:40:51 +0100 Subject: [PATCH 2/4] add a body to be fully compliant with the http spec --- meilisearch-http/src/routes/health.rs | 3 ++- meilisearch-http/tests/health.rs | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/meilisearch-http/src/routes/health.rs b/meilisearch-http/src/routes/health.rs index 5544e2cea..15ca2a5f5 100644 --- a/meilisearch-http/src/routes/health.rs +++ b/meilisearch-http/src/routes/health.rs @@ -9,5 +9,6 @@ pub fn services(cfg: &mut web::ServiceConfig) { #[get("/health")] async fn get_health() -> Result { - Ok(HttpResponse::Ok().finish()) + let payload = serde_json::json!({ "status": "ok" }); + Ok(HttpResponse::Ok().body(payload.to_string())) } diff --git a/meilisearch-http/tests/health.rs b/meilisearch-http/tests/health.rs index 57738e009..b14921f4f 100644 --- a/meilisearch-http/tests/health.rs +++ b/meilisearch-http/tests/health.rs @@ -6,6 +6,7 @@ async fn test_healthyness() { // Check that the server is healthy - let (_response, status_code) = server.get_health().await; + let (response, status_code) = server.get_health().await; assert_eq!(status_code, 200); + assert_eq!(response["status"], "ok"); } From 018cadc59845e1a6eac2f29a0770613eb234dd5d Mon Sep 17 00:00:00 2001 From: tamo Date: Tue, 16 Mar 2021 14:02:14 +0100 Subject: [PATCH 3/4] follow the IBM convention --- meilisearch-http/src/routes/health.rs | 2 +- meilisearch-http/tests/health.rs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/meilisearch-http/src/routes/health.rs b/meilisearch-http/src/routes/health.rs index 15ca2a5f5..053790d61 100644 --- a/meilisearch-http/src/routes/health.rs +++ b/meilisearch-http/src/routes/health.rs @@ -9,6 +9,6 @@ pub fn services(cfg: &mut web::ServiceConfig) { #[get("/health")] async fn get_health() -> Result { - let payload = serde_json::json!({ "status": "ok" }); + let payload = serde_json::json!({ "status": "available" }); Ok(HttpResponse::Ok().body(payload.to_string())) } diff --git a/meilisearch-http/tests/health.rs b/meilisearch-http/tests/health.rs index b14921f4f..2be66887f 100644 --- a/meilisearch-http/tests/health.rs +++ b/meilisearch-http/tests/health.rs @@ -8,5 +8,5 @@ async fn test_healthyness() { let (response, status_code) = server.get_health().await; assert_eq!(status_code, 200); - assert_eq!(response["status"], "ok"); + assert_eq!(response["status"], "available"); } From d4b1331a0ae4b485c467bb09e11b537ca7f6fff3 Mon Sep 17 00:00:00 2001 From: Irevoire Date: Thu, 18 Mar 2021 11:54:10 +0100 Subject: [PATCH 4/4] use the json method instead of the body method in the creation of the response --- meilisearch-http/src/routes/health.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/meilisearch-http/src/routes/health.rs b/meilisearch-http/src/routes/health.rs index 053790d61..8d42b79bc 100644 --- a/meilisearch-http/src/routes/health.rs +++ b/meilisearch-http/src/routes/health.rs @@ -10,5 +10,5 @@ pub fn services(cfg: &mut web::ServiceConfig) { #[get("/health")] async fn get_health() -> Result { let payload = serde_json::json!({ "status": "available" }); - Ok(HttpResponse::Ok().body(payload.to_string())) + Ok(HttpResponse::Ok().json(payload)) }