mirror of
https://github.com/yusing/godoxy.git
synced 2026-04-25 10:18:59 +02:00
Improved healthcheck, idlewatcher support for loadbalanced routes, bug fixes
This commit is contained in:
30
internal/watcher/health/json.go
Normal file
30
internal/watcher/health/json.go
Normal file
@@ -0,0 +1,30 @@
|
||||
package health
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"time"
|
||||
|
||||
"github.com/yusing/go-proxy/internal/net/types"
|
||||
)
|
||||
|
||||
type JSONRepresentation struct {
|
||||
Name string
|
||||
Config *HealthCheckConfig
|
||||
Status Status
|
||||
Started time.Time
|
||||
Uptime time.Duration
|
||||
URL types.URL
|
||||
Extra map[string]any
|
||||
}
|
||||
|
||||
func (jsonRepr *JSONRepresentation) MarshalJSON() ([]byte, error) {
|
||||
return json.Marshal(map[string]any{
|
||||
"name": jsonRepr.Name,
|
||||
"config": jsonRepr.Config,
|
||||
"started": jsonRepr.Started.Unix(),
|
||||
"status": jsonRepr.Status.String(),
|
||||
"uptime": jsonRepr.Uptime.Seconds(),
|
||||
"url": jsonRepr.URL.String(),
|
||||
"extra": jsonRepr.Extra,
|
||||
})
|
||||
}
|
||||
Reference in New Issue
Block a user