mirror of
https://github.com/foomo/sesamy-go.git
synced 2025-10-16 12:35:43 +00:00
feat: pass through cookies
This commit is contained in:
parent
f8fcacca2a
commit
9331d10e0d
@ -5,7 +5,6 @@ import (
|
||||
"fmt"
|
||||
"io"
|
||||
"net/http"
|
||||
"strings"
|
||||
|
||||
"github.com/ThreeDotsLabs/watermill/message"
|
||||
"github.com/foomo/sesamy-go/pkg/encoding/gtag"
|
||||
@ -98,17 +97,17 @@ func (p *Publisher) Publish(topic string, messages ...*message.Message) error {
|
||||
}
|
||||
|
||||
for s, s2 := range msg.Metadata {
|
||||
if s == "Cookie" {
|
||||
for _, s3 := range strings.Split(s2, "; ") {
|
||||
val := strings.Split(s3, "=")
|
||||
req.AddCookie(&http.Cookie{
|
||||
Name: val[0],
|
||||
Value: strings.Join(val[1:], "="),
|
||||
})
|
||||
}
|
||||
} else {
|
||||
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: strings.Join(val[1:], "="),
|
||||
// })
|
||||
// }
|
||||
// } else {
|
||||
req.Header.Set(s, s2)
|
||||
// }
|
||||
}
|
||||
|
||||
l := p.l.With(
|
||||
|
||||
@ -131,9 +131,7 @@ func (s *Subscriber) handle(l *zap.Logger, r *http.Request, payload *gtag.Payloa
|
||||
|
||||
msg := message.NewMessage(s.uuidFunc(), data)
|
||||
l = l.With(zap.String("message_id", msg.UUID))
|
||||
// if labeler, ok := keellog.LabelerFromRequest(r); ok {
|
||||
// labeler.Add(zap.String("message_id", msg.UUID))
|
||||
// }
|
||||
|
||||
if payload.EventName != nil {
|
||||
msg.Metadata.Set(MetadataEventName, gtag.Get(payload.EventName).String())
|
||||
}
|
||||
@ -142,14 +140,6 @@ func (s *Subscriber) handle(l *zap.Logger, r *http.Request, payload *gtag.Payloa
|
||||
for name, headers := range r.Header {
|
||||
msg.Metadata.Set(name, strings.Join(headers, ","))
|
||||
}
|
||||
//
|
||||
// if cookies := r.Cookies(); len(cookies) > 0 {
|
||||
// values := make([]string, len(cookies))
|
||||
// for i, cookie := range r.Cookies() {
|
||||
// values[i] = cookie.String()
|
||||
// }
|
||||
// msg.Metadata.Set("Cookie", strings.Join(values, "; "))
|
||||
// }
|
||||
|
||||
for k, v := range msg.Metadata {
|
||||
l = l.With(zap.String(k, v))
|
||||
|
||||
Loading…
Reference in New Issue
Block a user