From 158d3aacc866ff71767212707989a98563c08a35 Mon Sep 17 00:00:00 2001 From: mr Date: Wed, 23 Oct 2024 09:07:36 +0200 Subject: [PATCH] method --- tools/remote_caller.go | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/tools/remote_caller.go b/tools/remote_caller.go index bf1ce37..b6aac28 100644 --- a/tools/remote_caller.go +++ b/tools/remote_caller.go @@ -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) +}