summaryrefslogtreecommitdiff
path: root/internal/api
diff options
context:
space:
mode:
authorRobby Zambito <contact@robbyzambito.me>2025-08-07 18:40:37 -0400
committerRobby Zambito <contact@robbyzambito.me>2025-08-07 20:22:47 -0400
commitfc84e7774754340604c1bb7170eb25b1cd8da405 (patch)
tree41845781182333cf635a8f7de1594e7052c0a104 /internal/api
parentf0aef833d90d7caebe61352c1254c2c8583e4210 (diff)
Add valid responses for status endpoints
Diffstat (limited to 'internal/api')
-rw-r--r--internal/api/handlers.go63
1 files changed, 53 insertions, 10 deletions
diff --git a/internal/api/handlers.go b/internal/api/handlers.go
index fbd17a7..b08f686 100644
--- a/internal/api/handlers.go
+++ b/internal/api/handlers.go
@@ -150,8 +150,8 @@ func StatusHandler(w http.ResponseWriter, r *http.Request) {
}
jsonData, _ := json.Marshal(res)
-
- fmt.Fprintf(w, "%s", string(jsonData))
+ // fmt.Printf("Overall: %s\n", string(jsonData))
+ fmt.Fprint(w, string(jsonData))
}
func StatusServicesHandler(w http.ResponseWriter, r *http.Request) {
@@ -165,8 +165,31 @@ func StatusServicesHandler(w http.ResponseWriter, r *http.Request) {
Uptime float64 `json:"uptime"`
}
- var response []service
- _ = response
+ response := []service{}
+
+ response = append(response, service{
+ Id: ServiceAPIGateway,
+ Name: "API Gateway",
+ Description: "Core API services",
+ Icon: IconAPIGateway,
+ Status: StatusOperational,
+ ResponseTime: 50,
+ Uptime: 69.420,
+ })
+
+ response = append(response, service{
+ Id: "logs",
+ Name: "Log Warden",
+ Description: "The master of the Logs",
+ Icon: "📜",
+ Status: StatusOperational,
+ ResponseTime: 69,
+ Uptime: 99.999,
+ })
+
+ jsonData, _ := json.Marshal(response)
+ // fmt.Printf("ServicesStatus: %s\n", string(jsonData))
+ fmt.Fprint(w, string(jsonData))
}
func StatusMetricsHandler(w http.ResponseWriter, r *http.Request) {
@@ -176,6 +199,17 @@ func StatusMetricsHandler(w http.ResponseWriter, r *http.Request) {
RequestVolume int `json:"requestVolume"`
ErrorRate float64 `json:"errorRate"`
}
+
+ res := response{
+ Uptime: 90.5,
+ ResponseTime: 169,
+ RequestVolume: 5,
+ ErrorRate: 106.0,
+ }
+
+ jsonData, _ := json.Marshal(res)
+ // fmt.Printf("Metrics: %s\n", string(jsonData))
+ fmt.Fprintf(w, string(jsonData))
}
func StatusIncidentsHandler(w http.ResponseWriter, r *http.Request) {
@@ -188,8 +222,11 @@ func StatusIncidentsHandler(w http.ResponseWriter, r *http.Request) {
StartTime time.Time `json:"startTime"`
AffectedServices []string `json:"affectedServices"`
}
- var response []incident
- _ = response
+ response := []incident{}
+
+ jsonData, _ := json.Marshal(response)
+ // fmt.Printf("Incidents: %s\n", string(jsonData))
+ fmt.Fprintf(w, string(jsonData))
}
func StatusMaintenanceHandler(w http.ResponseWriter, r *http.Request) {
@@ -201,8 +238,11 @@ func StatusMaintenanceHandler(w http.ResponseWriter, r *http.Request) {
EndTime time.Time `json:"endTime"`
AffectedServices []string `json:"affectedServices"`
}
- var response []event
- _ = response
+ response := []event{}
+
+ jsonData, _ := json.Marshal(response)
+ // fmt.Printf("Events: %s\n", string(jsonData))
+ fmt.Fprintf(w, string(jsonData))
}
func StatusUptimeHandler(w http.ResponseWriter, r *http.Request) {
@@ -210,8 +250,11 @@ func StatusUptimeHandler(w http.ResponseWriter, r *http.Request) {
Date time.Time `json:"date"`
Uptime float64 `json:"uptime"`
}
- var response []event
- _ = response
+ response := []event{}
+
+ jsonData, _ := json.Marshal(response)
+ // fmt.Printf("Uptime: %s\n", string(jsonData))
+ fmt.Fprintf(w, string(jsonData))
}
// TODO: SUBSCRIBE TO EMAILS