1
0
mirror of https://github.com/go-micro/go-micro.git synced 2025-01-11 17:18:28 +02:00
go-micro/server/health_checker.go

22 lines
359 B
Go
Raw Normal View History

2015-01-14 01:31:27 +02:00
package server
import (
"io"
"net/http"
"net/url"
)
func registerHealthChecker(mux *http.ServeMux) {
req := &http.Request{
Method: "GET",
URL: &url.URL{
Path: HealthPath,
},
}
if _, path := mux.Handler(req); path != HealthPath {
mux.HandleFunc(HealthPath, func(w http.ResponseWriter, r *http.Request) {
io.WriteString(w, "ok")
})
}
}