Skip to content

Commit

Permalink
feat: handle cookies
Browse files Browse the repository at this point in the history
  • Loading branch information
franklinkim committed Mar 8, 2024
1 parent ffd63f3 commit 18754b0
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion integration/watermill/gtm/publisher.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"encoding/json"
"fmt"
"net/http"
"strings"

"github.com/ThreeDotsLabs/watermill/message"
mpv2 "github.com/foomo/sesamy-go/measurementprotocol/v2"
Expand Down Expand Up @@ -90,7 +91,17 @@ func (p *Publisher) Publish(topic string, messages ...*message.Message) error {
}

for s, s2 := range msg.Metadata {
req.Header.Set(s, s2)
if s == "Cookie" {
for _, s3 := range strings.Split(s2, "; ") {
val := strings.Split(s3, "=")
req.AddCookie(&http.Cookie{
Name: val[0],
Value: val[1],
})
}
} else {
req.Header.Set(s, s2)
}
}

// logFields := watermill.LogFields{
Expand Down

0 comments on commit 18754b0

Please sign in to comment.