From 72d5c64c2d9dd7e1f5c731579dc75be1a4ad5a02 Mon Sep 17 00:00:00 2001 From: mr Date: Tue, 22 Oct 2024 09:28:18 +0200 Subject: [PATCH] get with custom types --- tools/remote_caller.go | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/tools/remote_caller.go b/tools/remote_caller.go index 8480f62..6c7f36b 100644 --- a/tools/remote_caller.go +++ b/tools/remote_caller.go @@ -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 }