From ab8d92c8bbaeab98be2fc1c0028082c13ccadb62 Mon Sep 17 00:00:00 2001 From: Andy Librian Date: Sun, 7 Mar 2021 05:21:12 +0700 Subject: [PATCH] Add healthcheck endpoint --- pkg/server/server.go | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/pkg/server/server.go b/pkg/server/server.go index 4224919..f6e2ee6 100644 --- a/pkg/server/server.go +++ b/pkg/server/server.go @@ -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") != "" { @@ -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) +}