nic-chen commented on a change in pull request #847:
URL: https://github.com/apache/apisix-dashboard/pull/847#discussion_r528511848



##########
File path: api/internal/core/entity/format.go
##########
@@ -46,13 +50,35 @@ func NodesFormat(obj interface{}) interface{} {
                        nodes = append(nodes, node)
                }
                return nodes
-       }
+       case map[string]interface{}:
+               log.Infof("nodes type: %v", objType)
+               var strArr []string
+               value := obj.(map[string]interface{})
+               for key, val := range value {
+                       node := &Node{}
+                       strArr = strings.Split(key, ":")
+                       if len(strArr) != 2 {
+                               log.Warn("length of string array is not 2")
+                               return obj
+                       }
 
-       if nodes, ok := obj.([]*Node); ok {
-               return nodes
-       }
+                       port, err := strconv.Atoi(strArr[1])
+                       if err != nil {
+                               log.Errorf("parse int fail:", err)
+                               return obj
+                       }
 
-       if list, ok := obj.([]interface{}); ok {
+                       node.Host = strArr[0]
+                       node.Port = port
+                       node.Weight = int(val.(float64))

Review comment:
       updated.




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to