fix(api): corrected json marshaling for HealthInfo

This commit is contained in:
yusing
2025-08-16 23:05:29 +08:00
parent 90efa36193
commit 7a9b8b3fb9
3 changed files with 29 additions and 7 deletions

View File

@@ -54,23 +54,23 @@ func (info *HealthInfo) UnmarshalJSON(data []byte) error {
return nil
}
func GetHealthInfo() map[string]HealthInfo {
healthMap := make(map[string]HealthInfo, NumRoutes())
func GetHealthInfo() map[string]*HealthInfo {
healthMap := make(map[string]*HealthInfo, NumRoutes())
for r := range Iter {
healthMap[r.Name()] = getHealthInfo(r)
}
return healthMap
}
func getHealthInfo(r types.Route) HealthInfo {
func getHealthInfo(r types.Route) *HealthInfo {
mon := r.HealthMonitor()
if mon == nil {
return HealthInfo{
return &HealthInfo{
Status: types.StatusUnknown,
Detail: "n/a",
}
}
return HealthInfo{
return &HealthInfo{
Status: mon.Status(),
Uptime: mon.Uptime(),
Latency: mon.Latency(),