MCPcopy
hub / github.com/cortexlabs/cortex / HealthcheckHandler

Function HealthcheckHandler

pkg/dequeuer/http_handler.go:21–32  ·  view source on GitHub ↗
(isHealthy func() bool)

Source from the content-addressed store, hash-verified

19import "net/http"
20
21func HealthcheckHandler(isHealthy func() bool) http.HandlerFunc {
22 return func(w http.ResponseWriter, r *http.Request) {
23 if !isHealthy() {
24 w.WriteHeader(http.StatusInternalServerError)
25 _, _ = w.Write([]byte("unhealthy"))
26 return
27 }
28
29 w.WriteHeader(http.StatusOK)
30 _, _ = w.Write([]byte("healthy"))
31 }
32}

Callers 1

mainFunction · 0.92

Calls 1

WriteMethod · 0.80

Tested by

no test coverage detected