3
0
Files
corteza/pkg/healthcheck/http_handler.go
2020-07-11 13:24:58 +02:00

17 lines
322 B
Go

package healthcheck
import "net/http"
func HttpHandler() http.HandlerFunc {
return func(w http.ResponseWriter, r *http.Request) {
results := Defaults().Run(r.Context())
if results.Healthy() {
w.WriteHeader(http.StatusOK)
} else {
w.WriteHeader(http.StatusInternalServerError)
}
results.WriteTo(w)
}
}