From 8d93050636a9f88e0602090ea5d1376fd39c880d Mon Sep 17 00:00:00 2001 From: Gabriel Radureau Date: Tue, 5 May 2026 10:18:30 +0200 Subject: [PATCH] feat(server): add go_version to /api/info response (#54) Co-authored-by: Gabriel Radureau Co-committed-by: Gabriel Radureau --- adr/0026-composite-info-endpoint.md | 5 ++++- documentation/API.md | 3 ++- features/info/info.feature | 7 +++++++ pkg/server/server.go | 3 +++ 4 files changed, 16 insertions(+), 2 deletions(-) diff --git a/adr/0026-composite-info-endpoint.md b/adr/0026-composite-info-endpoint.md index 4230763..59826ba 100644 --- a/adr/0026-composite-info-endpoint.md +++ b/adr/0026-composite-info-endpoint.md @@ -141,10 +141,13 @@ We will implement a new `GET /api/info` endpoint that returns a JSON object with "build_date": "2026-05-04T08:00:00Z", "uptime_seconds": 1234, "cache_enabled": true, - "healthz_status": "healthy" + "healthz_status": "healthy", + "go_version": "go1.26.1" } ``` +The `go_version` field provides the Go runtime version via `runtime.Version()`, useful for ops debugging (e.g., identifying which Go version is running in production). + ### Rationale 1. **Performance**: Single HTTP request instead of 3-4 separate calls diff --git a/documentation/API.md b/documentation/API.md index 8f10c57..8367787 100644 --- a/documentation/API.md +++ b/documentation/API.md @@ -30,7 +30,8 @@ Reference document for all HTTP endpoints exposed by `dance-lessons-coach` serve "build_date": "2026-05-05", "uptime_seconds": 1234, "cache_enabled": true, - "healthz_status": "healthy" + "healthz_status": "healthy", + "go_version": "go1.26.1" } ``` diff --git a/features/info/info.feature b/features/info/info.feature index 8e36e4c..7d55cb8 100644 --- a/features/info/info.feature +++ b/features/info/info.feature @@ -36,3 +36,10 @@ Feature: Info Endpoint Then the response header "X-Cache" should be "MISS" When I request the info endpoint again Then the response header "X-Cache" should be "HIT" + + @go_version @critical + Scenario: go_version field is non-empty + Given the server is running + When I request the info endpoint + Then the status code should be 200 + And the response should contain "go_version" diff --git a/pkg/server/server.go b/pkg/server/server.go index 0e0fc2a..5f65e0f 100644 --- a/pkg/server/server.go +++ b/pkg/server/server.go @@ -9,6 +9,7 @@ import ( "net" "net/http" "os/signal" + "runtime" "syscall" "time" @@ -453,6 +454,7 @@ type InfoResponse struct { UptimeSeconds int64 `json:"uptime_seconds"` CacheEnabled bool `json:"cache_enabled"` HealthzStatus string `json:"healthz_status"` + GoVersion string `json:"go_version"` } // handleHealthz godoc @@ -500,6 +502,7 @@ func (s *Server) handleInfo(w http.ResponseWriter, r *http.Request) { UptimeSeconds: int64(time.Since(s.startedAt).Seconds()), CacheEnabled: s.cacheService != nil, HealthzStatus: "healthy", + GoVersion: runtime.Version(), } // Cache key