summaryrefslogtreecommitdiff
path: root/internal
diff options
context:
space:
mode:
authorRobby Zambito <contact@robbyzambito.me>2025-08-07 18:36:55 -0400
committerRobby Zambito <contact@robbyzambito.me>2025-08-07 20:22:47 -0400
commite94132f06b5cf24bdf29f0bf0953bcdf452d47c4 (patch)
tree1f8d626d9e52d09e3eaf5af0e7415e1d38b8f38f /internal
parent720e9f4e31e2bf5e654c516a6263dcf5f6e3e959 (diff)
Add API constants and initial overall status handler
Diffstat (limited to 'internal')
-rw-r--r--internal/api/handlers.go54
1 files changed, 54 insertions, 0 deletions
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) {