chore: make callbacks return same struct as /api/rawdata
This commit is contained in:
parent
78c27a261b
commit
a428f37e02
2 changed files with 42 additions and 33 deletions
|
|
@ -50,6 +50,38 @@ type RunTimeRepresentation struct {
|
|||
UDPServices map[string]*runtime.UDPServiceInfo `json:"udpServices,omitempty"`
|
||||
}
|
||||
|
||||
// TODO: think about this for longer
|
||||
func GetRunTimeRepresentation(runtimeConfiguration *runtime.Configuration) *RunTimeRepresentation {
|
||||
siRepr := make(map[string]*serviceInfoRepresentation, len(runtimeConfiguration.Services))
|
||||
for k, v := range runtimeConfiguration.Services {
|
||||
siRepr[k] = &serviceInfoRepresentation{
|
||||
ServiceInfo: v,
|
||||
ServerStatus: v.GetAllStatus(),
|
||||
}
|
||||
}
|
||||
|
||||
tcpSIRepr := make(map[string]*tcpServiceInfoRepresentation, len(runtimeConfiguration.Services))
|
||||
for k, v := range runtimeConfiguration.TCPServices {
|
||||
tcpSIRepr[k] = &tcpServiceInfoRepresentation{
|
||||
TCPServiceInfo: v,
|
||||
ServerStatus: v.GetAllStatus(),
|
||||
}
|
||||
}
|
||||
|
||||
result := RunTimeRepresentation{
|
||||
Routers: runtimeConfiguration.Routers,
|
||||
Middlewares: runtimeConfiguration.Middlewares,
|
||||
Services: siRepr,
|
||||
TCPRouters: runtimeConfiguration.TCPRouters,
|
||||
TCPMiddlewares: runtimeConfiguration.TCPMiddlewares,
|
||||
TCPServices: tcpSIRepr,
|
||||
UDPRouters: runtimeConfiguration.UDPRouters,
|
||||
UDPServices: runtimeConfiguration.UDPServices,
|
||||
}
|
||||
|
||||
return &result
|
||||
}
|
||||
|
||||
// Handler serves the configuration and status of Traefik on API endpoints.
|
||||
type Handler struct {
|
||||
staticConfig static.Configuration
|
||||
|
|
@ -124,32 +156,7 @@ func (h Handler) createRouter() *mux.Router {
|
|||
}
|
||||
|
||||
func (h Handler) getRuntimeConfiguration(rw http.ResponseWriter, request *http.Request) {
|
||||
siRepr := make(map[string]*serviceInfoRepresentation, len(h.runtimeConfiguration.Services))
|
||||
for k, v := range h.runtimeConfiguration.Services {
|
||||
siRepr[k] = &serviceInfoRepresentation{
|
||||
ServiceInfo: v,
|
||||
ServerStatus: v.GetAllStatus(),
|
||||
}
|
||||
}
|
||||
|
||||
tcpSIRepr := make(map[string]*tcpServiceInfoRepresentation, len(h.runtimeConfiguration.Services))
|
||||
for k, v := range h.runtimeConfiguration.TCPServices {
|
||||
tcpSIRepr[k] = &tcpServiceInfoRepresentation{
|
||||
TCPServiceInfo: v,
|
||||
ServerStatus: v.GetAllStatus(),
|
||||
}
|
||||
}
|
||||
|
||||
result := RunTimeRepresentation{
|
||||
Routers: h.runtimeConfiguration.Routers,
|
||||
Middlewares: h.runtimeConfiguration.Middlewares,
|
||||
Services: siRepr,
|
||||
TCPRouters: h.runtimeConfiguration.TCPRouters,
|
||||
TCPMiddlewares: h.runtimeConfiguration.TCPMiddlewares,
|
||||
TCPServices: tcpSIRepr,
|
||||
UDPRouters: h.runtimeConfiguration.UDPRouters,
|
||||
UDPServices: h.runtimeConfiguration.UDPServices,
|
||||
}
|
||||
result := GetRunTimeRepresentation(h.runtimeConfiguration)
|
||||
|
||||
rw.Header().Set("Content-Type", "application/json")
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue