Skip to content

Commit

Permalink
support posting forms
Browse files Browse the repository at this point in the history
  • Loading branch information
andreas-goebel committed Oct 4, 2023
1 parent 71e9300 commit cd32fbc
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions http/http.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit cd32fbc

Please sign in to comment.