diff --git a/routing/routes.go b/routing/routes.go index 19f38d3a19d411860dc6c4941054a13490208d85..b80eda13b89706dd75565319d5c818347b1ef576 100644 --- a/routing/routes.go +++ b/routing/routes.go @@ -21,25 +21,29 @@ func SetRoutes( router *f.App, config *configuration.Config, healthiness *bool ) router.Get( "/health", func( c *f.Ctx ) error { type response struct { - Status string `json:"status" validate:"oneof=passed failed"` + Status string `json:"status" validate:"oneof=pass fail"` } - c.Type( "json", "utf-8" ) + c.Set( "Content-Type", "application/health+json; charset=utf-8" ) - var res response + var res *response if *healthiness == false { - res = response{ - Status: "failed", + res = &response{ + Status: "fail", } c.Status( http.StatusServiceUnavailable ) } else { - res = response{ - Status: "passed", + res = &response{ + Status: "pass", } c.Status( http.StatusOK ) } - return c.JSON( res ) + resJson, err := json.Marshal( res ) + if err != nil { + return err + } + return c.SendString( string( resJson ) ) }) diff --git a/routing/routes_test.go b/routing/routes_test.go index 09bb4d10b211ec804b718779c2113cd78795ded7..f37924fa5750be46a135113252db71207b305625 100644 --- a/routing/routes_test.go +++ b/routing/routes_test.go @@ -88,7 +88,7 @@ func TestHealthRoute( t *testing.T ){ status := bodyContent[ "status" ].( string ) assert.Equal( t, http.StatusOK, res.StatusCode ) assert.Nil( t, err ) - assert.Equal( t, "passed", status ) + assert.Equal( t, "pass", status ) *healthiness = false @@ -98,7 +98,7 @@ func TestHealthRoute( t *testing.T ){ status = bodyContent[ "status" ].( string ) assert.Equal( t, http.StatusServiceUnavailable, res.StatusCode ) assert.Nil( t, err ) - assert.Equal( t, "failed", status ) + assert.Equal( t, "fail", status ) }