Skip to content

Commit

Permalink
Add healthcheck endpoint
Browse files Browse the repository at this point in the history
  • Loading branch information
andylibrian committed Mar 6, 2021
1 parent 7794f89 commit ab8d92c
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions pkg/server/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,8 @@ func (s *Server) setupRouter() (*httprouter.Router, error) {
router.POST("/api/v1/load_test", s.handleStartLoadTest)
router.DELETE("/api/v1/load_test", s.handleStopLoadTest)

router.GET("/healthz", s.handleHealthz)

// CORS
router.GlobalOPTIONS = http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
if r.Header.Get("Access-Control-Request-Method") != "" {
Expand Down Expand Up @@ -322,3 +324,7 @@ func (s *Server) handleStopLoadTest(responseWriter http.ResponseWriter, req *htt

responseWriter.WriteHeader(204)
}

func (s *Server) handleHealthz(responseWriter http.ResponseWriter, req *http.Request, _ httprouter.Params) {
responseWriter.WriteHeader(200)
}

0 comments on commit ab8d92c

Please # to comment.