// NewHandler creates a new health check http.Handler.
NewHandler creates a new health check http.Handler.
// NewHandler creates a new health check http . Handler .
func NewHandler(checker Checker, options ...HandlerOption) http.HandlerFunc {
	cfg := createConfig(options)
	return func(w http.ResponseWriter, r *http.Request) {
		result := withMiddleware(cfg.middleware, func(r *http.Request) CheckerResult {
			return checker.Check(r.Context())
		})(r)
		disableResponseCache(w)
		statusCode := mapHTTPStatusCode(result.Status, cfg.statusCodeUp, cfg.statusCodeDown)
		cfg.resultWriter.Write(&result, statusCode, w, r)
	}
}
func NewHandler ( checker Checker , options ... HandlerOption ) http . HandlerFunc { cfg := createConfig ( options ) return func ( w http . ResponseWriter , r * http . Request ) { result := withMiddleware ( cfg . middleware , func ( r * http . Request ) CheckerResult { return checker . Check ( r . Context ( ) ) } ) ( r ) disableResponseCache ( w ) statusCode := mapHTTPStatusCode ( result . Status , cfg . statusCodeUp , cfg . statusCodeDown ) cfg . resultWriter . Write ( & result , statusCode , w , r ) } }
NewHandler creates a new health check http.Handler.
NewHandler creates a new health check http . Handler .
// Do the check (with configured middleware) // Write HTTP response