etcdserver/api/etcdhttp/metrics.go
func NewHealthHandler(hfunc func() Health) http.HandlerFunc {
	return func(w http.ResponseWriter, r *http.Request) {
		if r.Method != http.MethodGet {
			w.Header().Set("Allow", http.MethodGet)
			http.Error(w, "Method Not Allowed", http.StatusMethodNotAllowed)
			return
		}
		h := hfunc()
		d, _ := json.Marshal(h)
		if h.Health != "true" {
			http.Error(w, string(d), http.StatusServiceUnavailable)
			return
		}
		w.WriteHeader(http.StatusOK)
		w.Write(d)
	}
}
func NewHealthHandler(hfunc func() Health) http.HandlerFunc {
	return func(w http.ResponseWriter, r *http.Request) {
		if r.Method != http.MethodGet {
			w.Header().Set("Allow", http.MethodGet)
			http.Error(w, "Method Not Allowed", http.StatusMethodNotAllowed)
			return
		}
		h := hfunc()
		d, _ := json.Marshal(h)
		if h.Health != "true" {
			http.Error(w, string(d), http.StatusServiceUnavailable)
			return
		}
		w.WriteHeader(http.StatusOK)
		w.Write(d)
	}
}
func NewHealthHandler ( hfunc func ( ) Health ) http . HandlerFunc { return func ( w http . ResponseWriter , r * http . Request ) { if r . Method != http . MethodGet { w . Header ( ) . Set ( " " , http . MethodGet ) http . Error ( w , " " , http . StatusMethodNotAllowed ) return } h := hfunc ( ) d , _ := json . Marshal ( h ) if h . Health != " " { http . Error ( w , string ( d ) , http . StatusServiceUnavailable ) return } w . WriteHeader ( http . StatusOK ) w . Write ( d ) } }
// NewHealthHandler handles '/health' requests.
NewHealthHandler handles / health requests .