@@ -2,12 +2,16 @@ package api
22
33import (
44 "net/http"
5+ "time"
56)
67
78// HealthResponse is returned by GET /v1/health.
89type HealthResponse struct {
9- Status string `json:"status"`
10- Version string `json:"version"`
10+ Status string `json:"status"`
11+ Version string `json:"version"`
12+ LogBackend string `json:"log_backend,omitempty"`
13+ SignerType string `json:"signer_type,omitempty"`
14+ Timestamp string `json:"timestamp"`
1115}
1216
1317// StatsResponse is returned by GET /v1/stats.
@@ -19,18 +23,20 @@ type StatsResponse struct {
1923}
2024
2125func (s * Server ) handleHealth (w http.ResponseWriter , r * http.Request ) {
26+ resp := HealthResponse {
27+ Version : s .version ,
28+ LogBackend : s .logBackend ,
29+ SignerType : s .signerType ,
30+ Timestamp : time .Now ().UTC ().Format (time .RFC3339 ),
31+ }
2232 // Probe DB connectivity via Stats (lightweight query).
2333 if _ , err := s .store .Stats (); err != nil {
24- writeJSON (w , http .StatusServiceUnavailable , HealthResponse {
25- Status : "degraded" ,
26- Version : s .version ,
27- })
34+ resp .Status = "degraded"
35+ writeJSON (w , http .StatusServiceUnavailable , resp )
2836 return
2937 }
30- writeJSON (w , http .StatusOK , HealthResponse {
31- Status : "ok" ,
32- Version : s .version ,
33- })
38+ resp .Status = "ok"
39+ writeJSON (w , http .StatusOK , resp )
3440}
3541
3642func (s * Server ) handleStats (w http.ResponseWriter , r * http.Request ) {
0 commit comments