package dockerhealth import ( "context" "net/http" ) var server = &http.Server{ Handler: new(httpHandler), Addr: "localhost:60000", } var Healthy bool = true func init() { go func() { server.ListenAndServe() }() } func Stop() { server.Shutdown(context.Background()) } type httpHandler struct { http.Handler } func (h *httpHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) { if Healthy { w.WriteHeader(http.StatusOK) } else { w.WriteHeader(http.StatusInternalServerError) } }