added an option to enable GCP healthcheck endpoints

This commit is contained in:
timothy-spencer
2019-03-20 14:29:44 -07:00
parent ca89bb833d
commit 3476daf322
3 changed files with 31 additions and 5 deletions
+17
View File
@@ -24,6 +24,23 @@ func (s *Server) ListenAndServe() {
}
}
// gcpHealthcheck handles healthcheck queries from GCP
func gcpHealthcheck(h http.Handler) http.Handler {
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
if r.URL.EscapedPath() == "/liveness_check" {
w.WriteHeader(http.StatusOK)
w.Write([]byte("OK"))
return
}
if r.URL.EscapedPath() == "/readiness_check" {
w.WriteHeader(http.StatusOK)
w.Write([]byte("OK"))
return
}
h.ServeHTTP(w, r)
})
}
// ServeHTTP constructs a net.Listener and starts handling HTTP requests
func (s *Server) ServeHTTP() {
HTTPAddress := s.Opts.HTTPAddress