mirror of
https://github.com/gravitl/netmaker.git
synced 2025-09-19 19:44:33 +08:00
fix(go): sort directly;
This commit is contained in:
parent
f4ab479593
commit
1337b63816
1 changed files with 6 additions and 1 deletions
|
@ -5,7 +5,10 @@ import (
|
|||
"github.com/gorilla/mux"
|
||||
"github.com/gravitl/netmaker/logger"
|
||||
"github.com/gravitl/netmaker/logic"
|
||||
"github.com/gravitl/netmaker/models"
|
||||
"net/http"
|
||||
"slices"
|
||||
"strings"
|
||||
)
|
||||
|
||||
func NetworkHandlers(r *mux.Router) {
|
||||
|
@ -25,7 +28,9 @@ func getNetworkGraph(w http.ResponseWriter, r *http.Request) {
|
|||
networkNodes = logic.AddStaticNodestoList(networkNodes)
|
||||
// return all the nodes in JSON/API format
|
||||
apiNodes := logic.GetAllNodesAPIWithLocation(networkNodes[:])
|
||||
logic.SortApiNodes(apiNodes[:])
|
||||
slices.SortFunc(apiNodes, func(a, b models.ApiNode) int {
|
||||
return strings.Compare(a.ID, b.ID)
|
||||
})
|
||||
w.WriteHeader(http.StatusOK)
|
||||
json.NewEncoder(w).Encode(apiNodes)
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue