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"
|
"fmt"
|
||||||
"io"
|
"io"
|
||||||
"net/http"
|
"net/http"
|
||||||
"strings"
|
|
||||||
|
|
||||||
"github.com/ThreeDotsLabs/watermill/message"
|
"github.com/ThreeDotsLabs/watermill/message"
|
||||||
"github.com/foomo/sesamy-go/pkg/encoding/gtag"
|
"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 {
|
for s, s2 := range msg.Metadata {
|
||||||
if s == "Cookie" {
|
// if s == "Cookie" {
|
||||||
for _, s3 := range strings.Split(s2, "; ") {
|
// for _, s3 := range strings.Split(s2, "; ") {
|
||||||
val := strings.Split(s3, "=")
|
// val := strings.Split(s3, "=")
|
||||||
req.AddCookie(&http.Cookie{
|
// req.AddCookie(&http.Cookie{
|
||||||
Name: val[0],
|
// Name: val[0],
|
||||||
Value: strings.Join(val[1:], "="),
|
// Value: strings.Join(val[1:], "="),
|
||||||
})
|
// })
|
||||||
}
|
// }
|
||||||
} else {
|
// } else {
|
||||||
req.Header.Set(s, s2)
|
req.Header.Set(s, s2)
|
||||||
}
|
// }
|
||||||
}
|
}
|
||||||
|
|
||||||
l := p.l.With(
|
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)
|
msg := message.NewMessage(s.uuidFunc(), data)
|
||||||
l = l.With(zap.String("message_id", msg.UUID))
|
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 {
|
if payload.EventName != nil {
|
||||||
msg.Metadata.Set(MetadataEventName, gtag.Get(payload.EventName).String())
|
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 {
|
for name, headers := range r.Header {
|
||||||
msg.Metadata.Set(name, strings.Join(headers, ","))
|
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 {
|
for k, v := range msg.Metadata {
|
||||||
l = l.With(zap.String(k, v))
|
l = l.With(zap.String(k, v))
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user