This commit is contained in:
mr 2024-10-23 09:07:36 +02:00
parent 55a25aba83
commit 158d3aacc8

View File

@ -119,3 +119,16 @@ func (caller *HTTPCaller) CallPut(url string, subpath string, body map[string]in
defer resp.Body.Close()
return io.ReadAll(resp.Body)
}
// CallRaw calls the Raw method on the HTTP server
func (caller *HTTPCaller) CallRaw(method string, url string, subpath string, body map[string]interface{}, content_type string) (*http.Response, error) {
postBody, _ := json.Marshal(body)
responseBody := bytes.NewBuffer(postBody)
req, err := http.NewRequest(method, url+subpath, responseBody)
if err != nil {
return nil, err
}
req.Header.Set("Content-Type", content_type)
client := &http.Client{}
return client.Do(req)
}