server.go 364 B

12345678910111213141516171819202122232425
  1. package probing
  2. import (
  3. "encoding/json"
  4. "net/http"
  5. "time"
  6. )
  7. func NewHandler() http.Handler {
  8. return &httpHealth{}
  9. }
  10. type httpHealth struct {
  11. }
  12. type Health struct {
  13. OK bool
  14. Now time.Time
  15. }
  16. func (h *httpHealth) ServeHTTP(w http.ResponseWriter, r *http.Request) {
  17. health := Health{OK: true, Now: time.Now()}
  18. e := json.NewEncoder(w)
  19. e.Encode(health)
  20. }