From cd32fbc94c7d4826cd78f0928c30d73c576c4c4f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andreas=20G=C3=B6bel?= Date: Wed, 4 Oct 2023 15:13:41 +0200 Subject: [PATCH] support posting forms --- http/http.go | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/http/http.go b/http/http.go index 0b2d99f..3f78840 100644 --- a/http/http.go +++ b/http/http.go @@ -268,10 +268,16 @@ func NewPutRequest(url string, body any) (*http.Request, error) { func newRequestWithBody(url string, body any, contentType string, method string) (*http.Request, error) { // Create payload if used - payload, err := json.Marshal(body) - if err != nil { - log.Error("Kafka", "Failed to marshal body: %s", err.Error()) - return nil, err + var payload []byte + var err error + if contentType == "application/json" { + payload, err = json.Marshal(body) + if err != nil { + log.Error("Kafka", "Failed to marshal body: %s", err.Error()) + return nil, err + } + } else { + payload = []byte(body.(string)) } // Create a new request with payload if used