simplify call to peer
This commit is contained in:
parent
dd3570fa37
commit
762cc19c14
@ -66,7 +66,7 @@ func (a *API) CheckRemotePeer(url string) (State, map[string]int) {
|
|||||||
// Check if the database is up
|
// Check if the database is up
|
||||||
caller := NewHTTPCaller(map[string]map[METHOD]string{})
|
caller := NewHTTPCaller(map[string]map[METHOD]string{})
|
||||||
var resp APIStatusResponse
|
var resp APIStatusResponse
|
||||||
b, err := caller.CallPost(url, "/status", []string{})
|
b, err := caller.CallPost(url, "/status", map[string]interface{}{})
|
||||||
fmt.Println("CheckRemotePeer", b, url, err)
|
fmt.Println("CheckRemotePeer", b, url, err)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return DEAD, map[string]int{}
|
return DEAD, map[string]int{}
|
||||||
|
@ -63,7 +63,7 @@ func (caller *HTTPCaller) CallDelete(url string, subpath string) ([]byte, error)
|
|||||||
return io.ReadAll(resp.Body)
|
return io.ReadAll(resp.Body)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (caller *HTTPCaller) CallPost(url string, subpath string, body interface{}) ([]byte, error) {
|
func (caller *HTTPCaller) CallPost(url string, subpath string, body map[string]interface{}) ([]byte, error) {
|
||||||
postBody, _ := json.Marshal(body)
|
postBody, _ := json.Marshal(body)
|
||||||
responseBody := bytes.NewBuffer(postBody)
|
responseBody := bytes.NewBuffer(postBody)
|
||||||
resp, err := http.Post(url+subpath, "application/json", responseBody)
|
resp, err := http.Post(url+subpath, "application/json", responseBody)
|
||||||
|
Loading…
Reference in New Issue
Block a user