Skip to content

Commit

Permalink
Add Content-Type header for event requests
Browse files Browse the repository at this point in the history
  • Loading branch information
mtneug committed Sep 11, 2024
1 parent 431b9d0 commit c77a3a5
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions pkg/events/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import (

"github.com/cenkalti/backoff/v4"
cloudevents "github.com/cloudevents/sdk-go/v2"
"github.com/nagare-media/engine/internal/pkg/mime"
)

type Client interface {
Expand Down Expand Up @@ -64,8 +65,7 @@ func (c *HTTPClient) SendAsyncAck(ctx context.Context, e cloudevents.Event) erro
func (c *HTTPClient) doSend(ctx context.Context, e cloudevents.Event, async bool) error {
buf := &bytes.Buffer{}
enc := json.NewEncoder(buf)
err := enc.Encode(e)
if err != nil {
if err := enc.Encode(e); err != nil {
return err
}

Expand All @@ -80,6 +80,8 @@ func (c *HTTPClient) doSend(ctx context.Context, e cloudevents.Event, async bool
req.URL.RawQuery = q.Encode()
}

req.Header.Set("Content-Type", mime.ApplicationCloudEventsJSON)

if c.Client == nil {
c.Client = http.DefaultClient
}
Expand Down

0 comments on commit c77a3a5

Please sign in to comment.