mirror of
https://github.com/yggdrasil-network/yggdrasil-go.git
synced 2024-11-23 18:15:24 +00:00
Fix admin socket list
This commit is contained in:
parent
3e10b964cb
commit
31c1c9b586
@ -43,7 +43,11 @@ type handler struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
type ListResponse struct {
|
type ListResponse struct {
|
||||||
List map[string][]string `json:"list"`
|
List map[string]ListEntry `json:"list"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type ListEntry struct {
|
||||||
|
Fields []string `json:"fields"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// AddHandler is called for each admin function to add the handler and help documentation to the API.
|
// AddHandler is called for each admin function to add the handler and help documentation to the API.
|
||||||
@ -66,9 +70,13 @@ func (a *AdminSocket) Init(c *yggdrasil.Core, state *config.NodeState, log *log.
|
|||||||
current := state.GetCurrent()
|
current := state.GetCurrent()
|
||||||
a.listenaddr = current.AdminListen
|
a.listenaddr = current.AdminListen
|
||||||
_ = a.AddHandler("list", []string{}, func(_ json.RawMessage) (interface{}, error) {
|
_ = a.AddHandler("list", []string{}, func(_ json.RawMessage) (interface{}, error) {
|
||||||
res := &ListResponse{}
|
res := &ListResponse{
|
||||||
|
List: map[string]ListEntry{},
|
||||||
|
}
|
||||||
for name, handler := range a.handlers {
|
for name, handler := range a.handlers {
|
||||||
res.List[name] = handler.args
|
res.List[name] = ListEntry{
|
||||||
|
Fields: handler.args,
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return res, nil
|
return res, nil
|
||||||
})
|
})
|
||||||
|
Loading…
Reference in New Issue
Block a user