add a body to be fully compliant with the http spec

This commit is contained in:
tamo 2021-03-16 11:40:51 +01:00
parent a2ac2de011
commit f6d0689967
No known key found for this signature in database
GPG Key ID: 7A6A970C96104F1B
2 changed files with 4 additions and 2 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::Ok().finish())
let payload = serde_json::json!({ "status": "ok" });
Ok(HttpResponse::Ok().body(payload.to_string()))
}

View File

@ -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");
}