diff --git a/go.mod b/go.mod new file mode 100644 index 0000000..6f7d3ce --- /dev/null +++ b/go.mod @@ -0,0 +1,3 @@ +module git.tordarus.net/Tordarus/dockerhealth + +go 1.17 diff --git a/health.go b/health.go new file mode 100644 index 0000000..725276b --- /dev/null +++ b/health.go @@ -0,0 +1,28 @@ +package dockerhealth + +import ( + "net/http" +) + +var server = &http.Server{ + Handler: new(httpHandler), + Addr: "localhost:60000", +} + +var Healthy bool = true + +func init() { + server.ListenAndServe() +} + +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) + } +}