Added http health check endpoint. (#137)

* Added http health check endpoint.

* Fixed performing POST on GET endpoint.

* Explicitly return http status 200 in health check endpoint.

* Updated changelog.
This commit is contained in:
Marvin Blum
2019-01-25 18:22:53 +01:00
committed by Joona Hoikkala
parent 7fbb5261c8
commit aff13a02fb
5 changed files with 40 additions and 0 deletions

View File

@ -71,6 +71,7 @@ func setupRouter(debug bool, noauth bool) http.Handler {
Debug: Config.General.Debug,
})
api.POST("/register", webRegisterPost)
api.GET("/health", healthCheck)
if noauth {
api.POST("/update", noAuth(webUpdatePost))
} else {
@ -406,3 +407,11 @@ func TestApiManyUpdateWithIpCheckHeaders(t *testing.T) {
}
Config.API.UseHeader = false
}
func TestApiHealthCheck(t *testing.T) {
router := setupRouter(false, false)
server := httptest.NewServer(router)
defer server.Close()
e := getExpect(t, server)
e.GET("/health").Expect().Status(http.StatusOK)
}