managarten/services/mana-notify/internal/handler/health.go
Till JS 7e931b1c6d refactor(services): rename Go services, remove -go suffix
mana-search-go → mana-search
mana-notify-go → mana-notify
mana-crawler-go → mana-crawler
mana-api-gateway-go → mana-api-gateway

Legacy NestJS versions are deleted, suffix no longer needed.
Updated all references in docker-compose, CLAUDE.md, package.json,
Forgejo workflows, and service package.json files.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-28 10:18:40 +01:00

38 lines
775 B
Go

package handler
import (
"net/http"
"time"
"github.com/manacore/mana-notify/internal/db"
)
type HealthHandler struct {
db *db.DB
startTime time.Time
}
func NewHealthHandler(database *db.DB) *HealthHandler {
return &HealthHandler{db: database, startTime: time.Now()}
}
func (h *HealthHandler) Health(w http.ResponseWriter, r *http.Request) {
dbOK := h.db.HealthCheck(r.Context()) == nil
status := "healthy"
if !dbOK {
status = "unhealthy"
}
writeJSON(w, http.StatusOK, map[string]any{
"status": status,
"version": "1.0.0",
"service": "mana-notify",
"uptime": time.Since(h.startTime).Seconds(),
"timestamp": time.Now().UTC().Format(time.RFC3339),
"services": map[string]any{
"database": dbOK,
"redis": true,
},
})
}