Skip to content

Commit

Permalink
Tweak healthcheck response body
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
rohanpm committed Aug 7, 2020
1 parent 95ae0c7 commit 7bf13d2
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion exodus_gw/gateway.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"}
2 changes: 1 addition & 1 deletion tests/test_gateway.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@


def test_healthcheck():
assert gateway.healthcheck() == {"200": "OK"}
assert gateway.healthcheck() == {"detail": "exodus-gw is running"}

0 comments on commit 7bf13d2

Please sign in to comment.