cleanup code

This commit is contained in:
Arthur Lu 2025-03-12 23:40:33 +00:00
parent 59d12d2e99
commit f37f89d5c7
3 changed files with 7 additions and 7 deletions

View File

@ -127,7 +127,7 @@ func handle_GET_Instance(c *gin.Context) {
func handle_GET_Login(c *gin.Context) { func handle_GET_Login(c *gin.Context) {
ctx := RequestContext{ ctx := RequestContext{
Cookies: nil, Cookies: nil,
Body: map[string]interface{}{}, Body: map[string]any{},
} }
res, err := RequestGetAPI("/proxmox/access/domains", ctx) res, err := RequestGetAPI("/proxmox/access/domains", ctx)
if err != nil { if err != nil {
@ -144,8 +144,8 @@ func handle_GET_Login(c *gin.Context) {
Name: "realm", Name: "realm",
} }
for _, v := range ctx.Body["data"].([]interface{}) { for _, v := range ctx.Body["data"].([]any) {
v = v.(map[string]interface{}) v = v.(map[string]any)
realm := Realm{} realm := Realm{}
err := mapstructure.Decode(v, &realm) err := mapstructure.Decode(v, &realm)
if err != nil { if err != nil {

View File

@ -43,7 +43,7 @@ type RequestType int
type RequestContext struct { type RequestContext struct {
Cookies map[string]string Cookies map[string]string
Body map[string]interface{} Body map[string]any
} }
// used in constructing instance cards in index // used in constructing instance cards in index

View File

@ -169,7 +169,7 @@ func get_API_resources(token string, csrf string) (map[uint]Instance, map[string
"PVEAuthCookie": token, "PVEAuthCookie": token,
"CSRFPreventionToken": csrf, "CSRFPreventionToken": csrf,
}, },
Body: map[string]interface{}{}, Body: map[string]any{},
} }
res, err := RequestGetAPI("/proxmox/cluster/resources", ctx) res, err := RequestGetAPI("/proxmox/cluster/resources", ctx)
if err != nil { if err != nil {
@ -180,8 +180,8 @@ func get_API_resources(token string, csrf string) (map[uint]Instance, map[string
nodes := map[string]Node{} nodes := map[string]Node{}
if res.StatusCode == 200 { // if we successfully retrieved the resources, then process it and return index if res.StatusCode == 200 { // if we successfully retrieved the resources, then process it and return index
for _, v := range ctx.Body["data"].([]interface{}) { for _, v := range ctx.Body["data"].([]any) {
m := v.(map[string]interface{}) m := v.(map[string]any)
if m["type"] == "node" { if m["type"] == "node" {
node := Node{} node := Node{}
err := mapstructure.Decode(v, &node) err := mapstructure.Decode(v, &node)