Corrected urlFormat() from peer_cache which constructed url with API's name at the end

This commit is contained in:
pb 2025-03-05 11:01:46 +01:00
parent fd3fef72d3
commit dbdccdb920

View File

@ -48,7 +48,7 @@ func (p *PeerCache) urlFormat(url string, dt tools.DataType) string {
url = strings.ReplaceAll(url, localhost, dt.API()+":8080/oc")
}
} else {
url = url + "/" + dt.API()
url = dt.API() + "/" + url
}
return url
}
@ -61,11 +61,13 @@ func (p *PeerCache) checkPeerStatus(peerID string, appName string) (*Peer, bool)
if code != 200 { // no peer no party
return nil, false
}
url := p.urlFormat(res.(*Peer).Url, tools.PEER) + "/status" // Format the URL
state, services := api.CheckRemotePeer(url)
res.(*Peer).ServicesState = services // Update the services states of the peer
access.UpdateOne(res, peerID) // Update the peer in the db
fmt.Println("URL peer : ", url)
fmt.Println("State : ", state)
fmt.Println("Services : ", services)
return res.(*Peer), state != tools.DEAD && services[appName] == 0 // Return the peer and its status
}