From 7bf13d2070809176af30a83434f8bde8fb67405b Mon Sep 17 00:00:00 2001 From: Rohan McGovern Date: Fri, 7 Aug 2020 14:05:40 +1000 Subject: [PATCH] Tweak healthcheck response body We want to give some simple static response here, but {"200": "OK"} isn't ideal. The response status is meant to be communicated in the HTTP status code. Embedding in the response body as well encourages callers to wrongly ignore the HTTP code and opens the possibility that the two codes might not match. Let's use the same response model as FastAPI uses by default for errors, which is: - no embedded response code - a "detail" attribute with human-oriented text This isn't a big deal since this is mainly for internal use, but let's get it right before adding other APIs. --- exodus_gw/gateway.py | 2 +- tests/test_gateway.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/exodus_gw/gateway.py b/exodus_gw/gateway.py index 7057056b..ee68deef 100755 --- a/exodus_gw/gateway.py +++ b/exodus_gw/gateway.py @@ -4,4 +4,4 @@ @app.get("/healthcheck") def healthcheck(): """Returns a successful response if the service is running.""" - return {"200": "OK"} + return {"detail": "exodus-gw is running"} diff --git a/tests/test_gateway.py b/tests/test_gateway.py index 11841928..87b820ed 100644 --- a/tests/test_gateway.py +++ b/tests/test_gateway.py @@ -2,4 +2,4 @@ def test_healthcheck(): - assert gateway.healthcheck() == {"200": "OK"} + assert gateway.healthcheck() == {"detail": "exodus-gw is running"}