29 lines
425 B
Go
29 lines
425 B
Go
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)
|
|
}
|
|
}
|