sabisan/internal/app/handlers_health.go

23 lines
511 B
Go
Raw Normal View History

2026-05-17 12:36:50 +00:00
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,
})
}