fixed schema and json tag, hide http://:0

This commit is contained in:
yusing
2024-10-20 11:04:44 +08:00
parent a278711421
commit c847fe4747
5 changed files with 16 additions and 10 deletions

View File

@@ -19,6 +19,10 @@ type JSONRepresentation struct {
}
func (jsonRepr *JSONRepresentation) MarshalJSON() ([]byte, error) {
url := jsonRepr.URL.String()
if url == "http://:0" {
url = ""
}
return json.Marshal(map[string]any{
"name": jsonRepr.Name,
"config": jsonRepr.Config,
@@ -27,7 +31,7 @@ func (jsonRepr *JSONRepresentation) MarshalJSON() ([]byte, error) {
"status": jsonRepr.Status.String(),
"uptime": jsonRepr.Uptime.Seconds(),
"uptimeStr": U.FormatDuration(jsonRepr.Uptime),
"url": jsonRepr.URL,
"url": url,
"extra": jsonRepr.Extra,
})
}