Remove unnessary early header write
This commit is contained in:

committed by
Felix Auringer

parent
2d71584464
commit
e14e9c9229
@ -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")`
|
||||
|
@ -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!"},
|
||||
|
@ -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)
|
||||
}
|
||||
|
Reference in New Issue
Block a user