From e14e9c9229c543c7dd7b50838b68678b9e5c8839 Mon Sep 17 00:00:00 2001 From: Jan-Eric Hellenberg Date: Wed, 28 Apr 2021 10:06:07 +0200 Subject: [PATCH] Remove unnessary early header write --- api/api.go | 2 +- api/health.go | 1 - api/health_test.go | 1 + 3 files changed, 2 insertions(+), 2 deletions(-) diff --git a/api/api.go b/api/api.go index 476fadb..afb89df 100644 --- a/api/api.go +++ b/api/api.go @@ -12,7 +12,7 @@ import ( // always returns a router for the newest version of our API. We // use gorilla/mux because it is more convenient than net/http, e.g. // when extracting path parameters. -func NewRouter() *mux.Router { +func NewRouter() http.Handler { router := mux.NewRouter() // this can later be restricted to a specific host with // `router.Host(...)` and to HTTPS with `router.Schemes("https")` diff --git a/api/health.go b/api/health.go index 2efae3c..3ba843f 100644 --- a/api/health.go +++ b/api/health.go @@ -7,7 +7,6 @@ import ( // Health tries to respond that the server is alive. // If it is not, the response won't reach the client. func Health(writer http.ResponseWriter, _ *http.Request) { - writer.WriteHeader(http.StatusOK) writeJson( writer, Message{"I'm alive!"}, diff --git a/api/health_test.go b/api/health_test.go index 62d22ed..06209de 100644 --- a/api/health_test.go +++ b/api/health_test.go @@ -19,5 +19,6 @@ func TestHealthRoute(t *testing.T) { _ = json.Unmarshal(recorder.Body.Bytes(), &result) assert.Equal(t, http.StatusOK, recorder.Code) + assert.Equal(t, "application/json", recorder.Header().Get("Content-Type")) assert.Equal(t, "I'm alive!", result.Message) }