23 lines
511 B
Go
23 lines
511 B
Go
|
|
package app
|
||
|
|
|
||
|
|
import (
|
||
|
|
"encoding/json"
|
||
|
|
"net/http"
|
||
|
|
)
|
||
|
|
|
||
|
|
func (s *Server) healthz(w http.ResponseWriter, r *http.Request) {
|
||
|
|
w.WriteHeader(http.StatusOK)
|
||
|
|
}
|
||
|
|
|
||
|
|
func (s *Server) readyz(w http.ResponseWriter, r *http.Request) {
|
||
|
|
dbHealthy := s.store.Ping(r.Context()) == nil
|
||
|
|
w.Header().Set("Content-Type", "application/json; charset=utf-8")
|
||
|
|
_ = json.NewEncoder(w).Encode(struct {
|
||
|
|
Version string `json:"version"`
|
||
|
|
DBHealthy bool `json:"db_healthy"`
|
||
|
|
}{
|
||
|
|
Version: s.cfg.Version,
|
||
|
|
DBHealthy: dbHealthy,
|
||
|
|
})
|
||
|
|
}
|