get with custom types
This commit is contained in:
parent
e45fefe883
commit
72d5c64c2d
@ -81,10 +81,14 @@ func (caller *HTTPCaller) CallDelete(url string, subpath string) ([]byte, error)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// CallPost calls the POST method on the HTTP server
|
// CallPost calls the POST method on the HTTP server
|
||||||
func (caller *HTTPCaller) CallPost(url string, subpath string, body map[string]interface{}) ([]byte, error) {
|
func (caller *HTTPCaller) CallPost(url string, subpath string, body map[string]interface{}, types ...string) ([]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)
|
contentType := "application/json"
|
||||||
|
if len(types) > 0 {
|
||||||
|
contentType = types[0]
|
||||||
|
}
|
||||||
|
resp, err := http.Post(url+subpath, contentType, responseBody)
|
||||||
if err != nil || resp == nil || resp.Body == nil {
|
if err != nil || resp == nil || resp.Body == nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user