From 9d9d253bf975ea3a276f161435b7263db3515b4c Mon Sep 17 00:00:00 2001 From: Nimatstar Date: Sun, 10 May 2026 20:58:43 +0100 Subject: [PATCH 1/2] feat: add GET /version endpoint --- cmd/paystream-api/main.go | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/cmd/paystream-api/main.go b/cmd/paystream-api/main.go index 63110c5..3073105 100644 --- a/cmd/paystream-api/main.go +++ b/cmd/paystream-api/main.go @@ -8,9 +8,12 @@ import ( "github.com/breedar/paystream/internal/health" ) +const version = "0.1.0" + func main() { mux := http.NewServeMux() mux.HandleFunc("GET /health", health.Handler) + mux.HandleFunc("GET /version", versionHandler) log.Println("paystream-api listening on :8080") if err := http.ListenAndServe(":8080", mux); err != nil { @@ -18,9 +21,13 @@ func main() { } } -// notFound is the default 404 handler used until the full router lands. +func versionHandler(w http.ResponseWriter, r *http.Request) { + w.Header().Set("Content-Type", "application/json") + json.NewEncoder(w).Encode(map[string]string{"version": version}) +} + func notFound(w http.ResponseWriter, r *http.Request) { w.Header().Set("Content-Type", "application/json") w.WriteHeader(http.StatusNotFound) json.NewEncoder(w).Encode(map[string]string{"error": "not found"}) -} +} \ No newline at end of file From 81f54081fc4ece8fb26cb4eae336e710b01ddba5 Mon Sep 17 00:00:00 2001 From: Nimatstar Date: Sun, 10 May 2026 20:58:45 +0100 Subject: [PATCH 2/2] feat: add service field to health response --- internal/health/health.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/internal/health/health.go b/internal/health/health.go index 428f398..cbe695d 100644 --- a/internal/health/health.go +++ b/internal/health/health.go @@ -18,4 +18,4 @@ func Handler(w http.ResponseWriter, r *http.Request) { Service: "paystream-api", Version: "0.1.0", }) -} +} \ No newline at end of file