wip: debug

This commit is contained in:
Kevin Franklin Kim 2024-09-26 21:17:50 +02:00
parent 7468cd8508
commit fcb18a0799
No known key found for this signature in database

View File

@ -3,6 +3,7 @@ package client
import (
"encoding/base64"
"encoding/json"
"fmt"
"net/http"
"github.com/foomo/sesamy-go/pkg/client"
@ -12,17 +13,20 @@ import (
func MPv2MiddlewarConsent(next client.MPv2Handler) client.MPv2Handler {
return func(r *http.Request, payload *mpv2.Payload[any]) error {
fmt.Println("---> 1")
cookie, err := r.Cookie(cookiebot.CookieName)
if err != nil || cookie.Value == "" {
return next(r, payload)
}
fmt.Println("---> 2")
data, err := base64.StdEncoding.DecodeString(cookie.Value)
if err != nil {
return next(r, payload)
}
var value cookiebot.Cookie
fmt.Println("---> 3")
if err := json.Unmarshal(data, &value); err != nil {
return next(r, payload)
}
@ -35,6 +39,7 @@ func MPv2MiddlewarConsent(next client.MPv2Handler) client.MPv2Handler {
return &ret
}
fmt.Println("---> 4")
payload.Consent = &mpv2.Consent{
AdUserData: consent(value.Marketing),
AdPersonalization: consent(value.Statistics),