INNER CODE UNIT · Go

Handler

begmaroman/go-micro-boilerplate · pkg/healthchecker/healthchecker.go:28

func Handler(check Check) http.Handler {
	mux := http.NewServeMux()
	mux.HandleFunc("/health", func(rw http.ResponseWriter, req *http.Request) {
		if req.Method != http.MethodGet {
			http.Error(rw, "not found", http.StatusNotFound)
			return
		}

		if check == nil {
			http.Error(rw, "health check callback is nil", http.StatusInternalServerError)
			return
		}

		if err := check(); err != nil {
			http.Error(rw, err.Error(), http.StatusInternalServerError)
			return
		}

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…