1291: Use 200 status code for healthcheck endpoint  r=MarinPostma a=irevoire

closes  #1282

Co-authored-by: tamo <tamo@meilisearch.com>
Co-authored-by: Irevoire <tamo@meilisearch.com>
This commit is contained in:
bors[bot] 2021-03-18 11:02:45 +00:00 committed by GitHub
commit 89d13706f1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 5 additions and 3 deletions

View File

@ -9,5 +9,6 @@ pub fn services(cfg: &mut web::ServiceConfig) {
#[get("/health")]
async fn get_health() -> Result<HttpResponse, ResponseError> {
Ok(HttpResponse::NoContent().finish())
let payload = serde_json::json!({ "status": "available" });
Ok(HttpResponse::Ok().json(payload))
}

View File

@ -6,6 +6,7 @@ async fn test_healthyness() {
// Check that the server is healthy
let (_response, status_code) = server.get_health().await;
assert_eq!(status_code, 204);
let (response, status_code) = server.get_health().await;
assert_eq!(status_code, 200);
assert_eq!(response["status"], "available");
}