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
This commit is contained in:
24
backend/internal/statuspage/handler.go
Normal file
24
backend/internal/statuspage/handler.go
Normal file
@@ -0,0 +1,24 @@
|
||||
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)
|
||||
}
|
||||
Reference in New Issue
Block a user