Skip to content

Commit

Permalink
Fix: set content-type to json on webhook call
Browse files Browse the repository at this point in the history
  • Loading branch information
runabol committed Nov 29, 2023
1 parent fe11653 commit b169468
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 0 deletions.
1 change: 1 addition & 0 deletions middleware/job/webhook.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ func callWebhook(webhook *tork.Webhook, body []byte) {
for attempts <= webhookDefaultMaxAttempts {
log.Debug().Msgf("Calling webhook %s (attempt: %d)", webhook.URL, attempts)
req, err := http.NewRequest("POST", webhook.URL, bytes.NewReader(body))
req.Header.Set("Content-Type", "application/json; charset=UTF-8")
if err != nil {
log.Error().Err(err).Msg("error creating webhook request")
return
Expand Down
2 changes: 2 additions & 0 deletions middleware/job/webhook_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,8 @@ func TestWebhookOKWithHeaders(t *testing.T) {
if err != nil {
panic(err)
}
ctype := r.Header.Get("Content-Type")
assert.Equal(t, "application/json; charset=UTF-8", ctype)
val := r.Header.Get("my-header")
assert.Equal(t, "my-value", val)
assert.Equal(t, "1234", js.ID)
Expand Down

0 comments on commit b169468

Please sign in to comment.