simplify call to peer

This commit is contained in:
mr 2024-08-23 17:35:29 +02:00
parent 1986143dd0
commit fd730741a4

View File

@ -3,6 +3,7 @@ package tools
import (
"encoding/json"
"errors"
"fmt"
"cloud.o-forge.io/core/oc-lib/dbs/mongo"
)
@ -66,14 +67,17 @@ func (a *API) CheckRemotePeer(url string) (State, map[string]int) {
caller := NewHTTPCaller(map[string]map[METHOD]string{})
var resp APIStatusResponse
b, err := caller.CallPost(url, "/status", []string{})
fmt.Println("CheckRemotePeer", b, err)
if err != nil {
return DEAD, map[string]int{}
}
json.Unmarshal(b, &resp)
fmt.Println("CheckRemotePeer2", b, err)
if resp.Data == nil {
return DEAD, map[string]int{}
}
new := map[string]int{}
fmt.Println("CheckRemotePeer", resp.Data.Services)
for k, v := range resp.Data.Services {
new[k] = ToState(v).EnumIndex()
}