mirror of
https://github.com/foomo/sesamy-go.git
synced 2025-10-16 12:35:43 +00:00
feat: pass through query
This commit is contained in:
parent
c22b610038
commit
519267b962
5
integration/watermill/mpv2/metadata.go
Normal file
5
integration/watermill/mpv2/metadata.go
Normal file
@ -0,0 +1,5 @@
|
||||
package mpv2
|
||||
|
||||
const (
|
||||
MetadataRequestQuery = "RequestQuery"
|
||||
)
|
||||
@ -119,17 +119,20 @@ func (p *Publisher) handle(l *zap.Logger, msg *message.Message) error {
|
||||
return errors.Wrap(err, "failed to create request")
|
||||
}
|
||||
|
||||
for s, s2 := range msg.Metadata {
|
||||
if s == "Cookie" {
|
||||
for _, s3 := range strings.Split(s2, "; ") {
|
||||
for key, value := range msg.Metadata {
|
||||
switch key {
|
||||
case "Cookie":
|
||||
for _, s3 := range strings.Split(value, "; ") {
|
||||
val := strings.Split(s3, "=")
|
||||
req.AddCookie(&http.Cookie{
|
||||
Name: val[0],
|
||||
Value: strings.Join(val[1:], "="),
|
||||
})
|
||||
}
|
||||
} else {
|
||||
req.Header.Set(s, s2)
|
||||
case MetadataRequestQuery:
|
||||
req.URL.RawQuery = value
|
||||
default:
|
||||
req.Header.Set(key, value)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -119,6 +119,10 @@ func (s *Subscriber) handle(l *zap.Logger, r *http.Request, payload *mpv2.Payloa
|
||||
l = l.With(zap.String("message_id", msg.UUID))
|
||||
msg.SetContext(context.WithoutCancel(r.Context()))
|
||||
|
||||
// store query
|
||||
msg.Metadata.Set(MetadataRequestQuery, r.URL.RawQuery)
|
||||
|
||||
// store header
|
||||
for name, headers := range r.Header {
|
||||
msg.Metadata.Set(name, strings.Join(headers, ","))
|
||||
}
|
||||
|
||||
@ -20,7 +20,11 @@ type (
|
||||
path string
|
||||
host string
|
||||
cookies []string
|
||||
// To create a new secret, navigate in the Google Analytics UI to:
|
||||
// Admin > Data Streams > choose your stream > Measurement Protocol > Create
|
||||
apiSecret string
|
||||
// Measurement ID. The identifier for a Data Stream. Found in the Google Analytics UI under:
|
||||
// Admin > Data Streams > choose your stream > Measurement ID
|
||||
measurementID string
|
||||
protocolVersion string
|
||||
httpClient *http.Client
|
||||
@ -139,6 +143,7 @@ func (c *MPv2) SendRaw(r *http.Request, payload *mpv2.Payload[any]) error {
|
||||
return errors.Wrap(err, "failed to create request")
|
||||
}
|
||||
|
||||
// query
|
||||
qry := req.URL.Query()
|
||||
if len(c.apiSecret) > 0 {
|
||||
qry.Add("api_secret", c.apiSecret)
|
||||
|
||||
Loading…
Reference in New Issue
Block a user