From 62705cc9b93ebeb9542ca8bee4f65467573d2c76 Mon Sep 17 00:00:00 2001 From: mr Date: Tue, 15 Oct 2024 10:23:07 +0200 Subject: [PATCH] include oc in racine path for remote calling --- models/peer/peer_cache.go | 4 ++-- tools/api.go | 8 ++++---- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/models/peer/peer_cache.go b/models/peer/peer_cache.go index 4c4c6a2..42b0479 100644 --- a/models/peer/peer_cache.go +++ b/models/peer/peer_cache.go @@ -43,9 +43,9 @@ func (p *PeerCache) urlFormat(url string, dt tools.DataType) string { r := regexp.MustCompile("(" + localhost + ":[0-9]+)") t := r.FindString(url) if t != "" { - url = strings.Replace(url, t, dt.API()+":8080", -1) + url = strings.Replace(url, t, dt.API()+":8080/oc", -1) } else { - url = strings.ReplaceAll(url, localhost, dt.API()+":8080") + url = strings.ReplaceAll(url, localhost, dt.API()+":8080/oc") } } else { url = url + "/" + dt.API() diff --git a/tools/api.go b/tools/api.go index 479f3ca..a8408ee 100644 --- a/tools/api.go +++ b/tools/api.go @@ -91,7 +91,7 @@ func (a *API) CheckRemotePeer(url string) (State, map[string]int) { } // CheckRemoteAPIs checks the state of remote APIs from your proper OC -func (a *API) CheckRemoteAPIs(urls map[string]string) (State, map[string]string, error) { +func (a *API) CheckRemoteAPIs(apis []DataType) (State, map[string]string, error) { // Check if the database is up new := map[string]string{} caller := NewHTTPCaller(map[DataType]map[METHOD]string{}) // Create a new http caller @@ -99,9 +99,9 @@ func (a *API) CheckRemoteAPIs(urls map[string]string) (State, map[string]string, e := "" state := ALIVE reachable := false - for appName, url := range urls { // Check the state of each remote API in the list + for _, api := range apis { // Check the state of each remote API in the list var resp APIStatusResponse - b, err := caller.CallGet(url, "/version/status") // Call the status endpoint of the remote API (standard OC status endpoint) + b, err := caller.CallGet(api.API()+":8080", "/oc/version/status") // Call the status endpoint of the remote API (standard OC status endpoint) if err != nil { state = REDUCED_SERVICE // If a remote API is not reachable, return reduced service continue @@ -111,7 +111,7 @@ func (a *API) CheckRemoteAPIs(urls map[string]string) (State, map[string]string, state = REDUCED_SERVICE // If the response is empty, return reduced service continue } - new[appName] = resp.Data.State + new[api.String()] = resp.Data.State if resp.Data.Code > code { code = resp.Data.Code e += resp.Error