| khenaidoo | 59ce9dd | 2019-11-11 13:05:32 -0500 | [diff] [blame] | 1 | package probing |
| 2 | |||||
| 3 | import ( | ||||
| 4 | "encoding/json" | ||||
| 5 | "net/http" | ||||
| 6 | "time" | ||||
| 7 | ) | ||||
| 8 | |||||
| 9 | func NewHandler() http.Handler { | ||||
| 10 | return &httpHealth{} | ||||
| 11 | } | ||||
| 12 | |||||
| 13 | type httpHealth struct { | ||||
| 14 | } | ||||
| 15 | |||||
| 16 | type Health struct { | ||||
| 17 | OK bool | ||||
| 18 | Now time.Time | ||||
| 19 | } | ||||
| 20 | |||||
| 21 | func (h *httpHealth) ServeHTTP(w http.ResponseWriter, r *http.Request) { | ||||
| 22 | health := Health{OK: true, Now: time.Now()} | ||||
| 23 | e := json.NewEncoder(w) | ||||
| 24 | e.Encode(health) | ||||
| 25 | } | ||||