//Handler for /nodemanager/getlistnodes //mode: GET //url: /nodemanager/getlistnodes //return: array of PubKey func nodeGetListNodesHandler(nm *nodemanager.NodeManager) http.HandlerFunc { return func(w http.ResponseWriter, r *http.Request) { logger.Info("Get list nodes") // var list ListNodes // for _, PubKey := range nm.PubKeyList { // list.PubKey = append(list.PubKey, string(PubKey[:])) // } wh.SendJSON(w, nm.PubKeyList) } }
//Handler for /nodemanager/gettransports //mode: GET //url: /nodemanager/gettransports?id=value func nodeGetTransportsHandler(nm *nodemanager.NodeManager) http.HandlerFunc { return func(w http.ResponseWriter, r *http.Request) { logger.Info("Get transport from Node") nodeID := r.FormValue("id") if nodeID == "" { wh.Error400(w, "Missing Node id") return } i, err := strconv.Atoi(nodeID) if err != nil { wh.Error400(w, "Node id must be integer") return } if len(nm.PubKeyList) < i { wh.Error400(w, "Invalid Node id") return } wh.SendJSON(w, nm.GetTransportsFromNode(i)) } }