From e94132f06b5cf24bdf29f0bf0953bcdf452d47c4 Mon Sep 17 00:00:00 2001 From: Robby Zambito Date: Thu, 7 Aug 2025 18:36:55 -0400 Subject: Add API constants and initial overall status handler --- internal/api/handlers.go | 54 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 54 insertions(+) (limited to 'internal') diff --git a/internal/api/handlers.go b/internal/api/handlers.go index 194401d..eaba445 100644 --- a/internal/api/handlers.go +++ b/internal/api/handlers.go @@ -73,6 +73,39 @@ func CreateLoginHandler(logs *[LogLength]string, n *int, logChan chan string) ht } } +const ( + StatusOperational = "operational" + StatusDegraded = "degraded" + StatusDown = "down" +) + +const ( + IconAPIGateway = "🔗" + IconWeb = "🌐" + IconAuth = "🔐" + IconDB = "🗄️" + IconStorage = "📁" + IconNotifications = "📧" + IconSearch = "🔍" + IconAnalytics = "📊" +) + +const ( + SeverityMinor = "minor" + SeverityMajor = "major" +) + +const ( + ServiceAPIGateway = "api" + ServiceWeb = "web" + ServiceAuth = "auth" + ServiceDB = "database" + ServiceStorage = "storage" + ServiceNotifications = "notifications" + ServiceSearch = "search" + ServiceAnalytics = "analytics" +) + func StatusHandler(w http.ResponseWriter, r *http.Request) { type response struct { Status string `json:"status"` @@ -82,6 +115,27 @@ func StatusHandler(w http.ResponseWriter, r *http.Request) { ActiveIncidents int `json:"activeIncidents"` ScheduledMaintenance int `json:"scheduledMaintenance"` } + + // res := response{ + // Status: StatusDown, + // Description: "Everything is on fire", + // Uptime: 0.0, + // ResponseTime: 0.0, + // ActiveIncidents: 9001, + // ScheduledMaintenance: 0, + // } + res := response{ + Status: StatusDegraded, + Description: "Everything is not great", + Uptime: 50.0, + ResponseTime: 20000, + ActiveIncidents: 9001, + ScheduledMaintenance: 1, + } + + jsonData, _ := json.Marshal(res) + + fmt.Fprintf(w, "%s", string(jsonData)) } func StatusServicesHandler(w http.ResponseWriter, r *http.Request) { -- cgit