Skip to content

Commit

Permalink
revert ServeHealth
Browse files Browse the repository at this point in the history
  • Loading branch information
nopcoder committed Nov 25, 2020
1 parent 3bf4812 commit f4216c2
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
2 changes: 1 addition & 1 deletion api/handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ func (s *Handler) BasicAuth() func(accessKey, secretKey string) (user *models.Us
func (s *Handler) setupHandler(api http.Handler, ui http.Handler) {
mux := http.NewServeMux()
// health check
mux.Handle("/_health", http.HandlerFunc(httputil.HealthHandler))
mux.Handle("/_health", httputil.ServeHealth())
// metrics
mux.Handle("/metrics", promhttp.Handler())
// pprof endpoint
Expand Down
12 changes: 7 additions & 5 deletions httputil/endpoints.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,13 @@ func SetHealthHandlerInfo(info string) {
healthInfo = info
}

func HealthHandler(w http.ResponseWriter, r *http.Request) {
_, _ = io.WriteString(w, "alive!")
if healthInfo != "" {
_, _ = io.WriteString(w, " "+healthInfo)
}
func ServeHealth() http.Handler {
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
_, _ = io.WriteString(w, "alive!")
if healthInfo != "" {
_, _ = io.WriteString(w, " "+healthInfo)
}
})
}

func ServePPROF(pprofPrefix string) http.Handler {
Expand Down

0 comments on commit f4216c2

Please sign in to comment.