Files
NexaVPN/backend/internal/statuspage/handler.go
nessi ff7eff8242 feat: add public status page with component health monitoring and system metrics visualization
Add statuspage package with service, handler, and types for exposing platform health. Implement GET /api/v1/status endpoint returning operational status, component health (API, database, gateway runtime), and control plane summary counts.

Add Service.Snapshot method querying database connectivity, user/device/gateway/service/policy counts, connected device count via handshake timestamps, and gateway runtime tel
2026-03-24 18:25:55 +01:00

25 lines
482 B
Go

package statuspage
import (
"net/http"
"nexavpn/backend/internal/apiutil"
)
type Handler struct {
service *Service
}
func NewHandler(service *Service) *Handler {
return &Handler{service: service}
}
func (h *Handler) PublicStatus(w http.ResponseWriter, r *http.Request) {
snapshot := h.service.Snapshot(r.Context())
statusCode := http.StatusOK
if snapshot.Status != "operational" {
statusCode = http.StatusServiceUnavailable
}
apiutil.JSON(w, statusCode, snapshot)
}