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")
|
return errors.Wrap(err, "failed to create request")
|
||||||
}
|
}
|
||||||
|
|
||||||
for s, s2 := range msg.Metadata {
|
for key, value := range msg.Metadata {
|
||||||
if s == "Cookie" {
|
switch key {
|
||||||
for _, s3 := range strings.Split(s2, "; ") {
|
case "Cookie":
|
||||||
|
for _, s3 := range strings.Split(value, "; ") {
|
||||||
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 {
|
case MetadataRequestQuery:
|
||||||
req.Header.Set(s, s2)
|
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))
|
l = l.With(zap.String("message_id", msg.UUID))
|
||||||
msg.SetContext(context.WithoutCancel(r.Context()))
|
msg.SetContext(context.WithoutCancel(r.Context()))
|
||||||
|
|
||||||
|
// store query
|
||||||
|
msg.Metadata.Set(MetadataRequestQuery, r.URL.RawQuery)
|
||||||
|
|
||||||
|
// store header
|
||||||
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, ","))
|
||||||
}
|
}
|
||||||
|
|||||||
@ -16,11 +16,15 @@ import (
|
|||||||
|
|
||||||
type (
|
type (
|
||||||
MPv2 struct {
|
MPv2 struct {
|
||||||
l *zap.Logger
|
l *zap.Logger
|
||||||
path string
|
path string
|
||||||
host string
|
host string
|
||||||
cookies []string
|
cookies []string
|
||||||
apiSecret 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
|
measurementID string
|
||||||
protocolVersion string
|
protocolVersion string
|
||||||
httpClient *http.Client
|
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")
|
return errors.Wrap(err, "failed to create request")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// query
|
||||||
qry := req.URL.Query()
|
qry := req.URL.Query()
|
||||||
if len(c.apiSecret) > 0 {
|
if len(c.apiSecret) > 0 {
|
||||||
qry.Add("api_secret", c.apiSecret)
|
qry.Add("api_secret", c.apiSecret)
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user