feat: scaffold files service

This commit is contained in:
Grendgi
2026-06-16 12:41:36 +03:00
commit cf92fda20e
25 changed files with 1665 additions and 0 deletions

View File

@@ -0,0 +1,27 @@
package handler
import (
"net/http"
"github.com/jackc/pgx/v5/pgxpool"
)
type HealthHandler struct {
pool *pgxpool.Pool
}
func NewHealthHandler(pool *pgxpool.Pool) *HealthHandler {
return &HealthHandler{pool: pool}
}
func (h *HealthHandler) Healthz(w http.ResponseWriter, _ *http.Request) {
writeJSON(w, http.StatusOK, map[string]string{"status": "ok"})
}
func (h *HealthHandler) Readyz(w http.ResponseWriter, r *http.Request) {
if err := h.pool.Ping(r.Context()); err != nil {
writeInternalError(w, r, err, "database unavailable")
return
}
writeJSON(w, http.StatusOK, map[string]string{"status": "ready"})
}