mirror of
https://github.com/Memo-2023/mana-monorepo.git
synced 2026-05-14 20:21:09 +02:00
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>
38 lines
775 B
Go
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,
|
|
},
|
|
})
|
|
}
|