Skip to content

Commit

Permalink
fix: bug apache#749
Browse files Browse the repository at this point in the history
  • Loading branch information
johzchen committed Nov 9, 2020
1 parent 8c40e0f commit a93cc20
Showing 1 changed file with 20 additions and 2 deletions.
22 changes: 20 additions & 2 deletions api/internal/core/entity/format.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ import (
)

func NodesFormat(obj interface{}) interface{} {
var nodes []*Node
if value, ok := obj.(map[string]float64); ok {
var nodes []*Node
var strArr []string
for key, val := range value {
node := &Node{}
Expand All @@ -48,5 +48,23 @@ func NodesFormat(obj interface{}) interface{} {
return nodes
}

return obj
if nodes, ok := obj.([]*Node); ok {
return nodes
}

if value, ok := obj.(map[string]interface{}); ok {

}

list := obj.([]interface{})
for _, v := range list {
val := v.(map[string]interface{})
node := &Node{}
node.Host = val["host"].(string)
node.Port = int(val["port"].(float64))
node.Weight = int(val["weight"].(float64))
nodes = append(nodes, node)
}

return nodes
}

0 comments on commit a93cc20

Please sign in to comment.