move getAPI request interface body to parameter,

move VMPath and FormatNumber methods to common utils
This commit is contained in:
2025-06-30 23:44:28 +00:00
parent a62fc83386
commit 8c339794b3
6 changed files with 100 additions and 89 deletions

View File

@@ -26,9 +26,10 @@ func GetLoginRealms() ([]Realm, error) {
ctx := common.RequestContext{
Cookies: nil,
Body: map[string]any{},
//Body: map[string]any{},
}
res, code, err := common.RequestGetAPI("/proxmox/access/domains", ctx)
body := map[string]any{}
res, code, err := common.RequestGetAPI("/proxmox/access/domains", ctx, &body)
if err != nil {
return realms, err
}
@@ -36,7 +37,7 @@ func GetLoginRealms() ([]Realm, error) {
return realms, fmt.Errorf("request to /proxmox/access/domains resulted in %+v", res)
}
for _, v := range ctx.Body["data"].([]any) {
for _, v := range body["data"].([]any) {
v = v.(map[string]any)
realm := Realm{}
err := mapstructure.Decode(v, &realm)