feat(server): add go_version to /api/info response

Adds a "go_version" field to InfoResponse, populated via runtime.Version().
Useful for ops debugging (which Go version is running in production?).
BDD scenario @critical asserts the field is non-empty. Doc + ADR-0026
updated.
This commit is contained in:
2026-05-05 10:17:22 +02:00
parent 42d165624b
commit 86831a3ce4
4 changed files with 16 additions and 2 deletions

View File

@@ -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", "build_date": "2026-05-04T08:00:00Z",
"uptime_seconds": 1234, "uptime_seconds": 1234,
"cache_enabled": true, "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 ### Rationale
1. **Performance**: Single HTTP request instead of 3-4 separate calls 1. **Performance**: Single HTTP request instead of 3-4 separate calls

View File

@@ -30,7 +30,8 @@ Reference document for all HTTP endpoints exposed by `dance-lessons-coach` serve
"build_date": "2026-05-05", "build_date": "2026-05-05",
"uptime_seconds": 1234, "uptime_seconds": 1234,
"cache_enabled": true, "cache_enabled": true,
"healthz_status": "healthy" "healthz_status": "healthy",
"go_version": "go1.26.1"
} }
``` ```

View File

@@ -36,3 +36,10 @@ Feature: Info Endpoint
Then the response header "X-Cache" should be "MISS" Then the response header "X-Cache" should be "MISS"
When I request the info endpoint again When I request the info endpoint again
Then the response header "X-Cache" should be "HIT" 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"

View File

@@ -9,6 +9,7 @@ import (
"net" "net"
"net/http" "net/http"
"os/signal" "os/signal"
"runtime"
"syscall" "syscall"
"time" "time"
@@ -453,6 +454,7 @@ type InfoResponse struct {
UptimeSeconds int64 `json:"uptime_seconds"` UptimeSeconds int64 `json:"uptime_seconds"`
CacheEnabled bool `json:"cache_enabled"` CacheEnabled bool `json:"cache_enabled"`
HealthzStatus string `json:"healthz_status"` HealthzStatus string `json:"healthz_status"`
GoVersion string `json:"go_version"`
} }
// handleHealthz godoc // handleHealthz godoc
@@ -500,6 +502,7 @@ func (s *Server) handleInfo(w http.ResponseWriter, r *http.Request) {
UptimeSeconds: int64(time.Since(s.startedAt).Seconds()), UptimeSeconds: int64(time.Since(s.startedAt).Seconds()),
CacheEnabled: s.cacheService != nil, CacheEnabled: s.cacheService != nil,
HealthzStatus: "healthy", HealthzStatus: "healthy",
GoVersion: runtime.Version(),
} }
// Cache key // Cache key