get with custom types

This commit is contained in:
mr 2024-10-22 09:28:18 +02:00
parent e45fefe883
commit 72d5c64c2d

View File

@ -81,10 +81,14 @@ func (caller *HTTPCaller) CallDelete(url string, subpath string) ([]byte, error)
}
// 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)
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 {
return nil, err
}