From 4afb76cea0a1819265f773ae71900603977e68c2 Mon Sep 17 00:00:00 2001 From: Robin Dittmar Date: Fri, 3 Jul 2026 10:01:33 +0200 Subject: [PATCH] Added /health endpoint --- cmd/api-server/main.go | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/cmd/api-server/main.go b/cmd/api-server/main.go index 9916e3c..f20c758 100644 --- a/cmd/api-server/main.go +++ b/cmd/api-server/main.go @@ -17,6 +17,10 @@ type ApiResponse struct { Form map[string]string `json:"form"` } +type HealthResponse struct { + Status string `json:"status"` +} + func main() { http.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) { var resp ApiResponse @@ -54,6 +58,22 @@ func main() { } }) + http.HandleFunc("/health", func(w http.ResponseWriter, r *http.Request) { + resp := HealthResponse{Status: "ok"} + + b, err := json.Marshal(&resp) + if err != nil { + log.Println(err) + return + } + + _, err = w.Write(b) + if err != nil { + log.Println(err) + return + } + }) + fmt.Println("Listening on localhost:8080") log.Fatal(http.ListenAndServe("localhost:8080", nil)) }