github.com/prebid/prebid-server/v2@v2.18.0/usersync/encoder.go (about) 1 package usersync 2 3 import ( 4 "encoding/base64" 5 6 "github.com/prebid/prebid-server/v2/util/jsonutil" 7 ) 8 9 type Encoder interface { 10 // Encode a cookie into a base 64 string 11 Encode(c *Cookie) (string, error) 12 } 13 14 type Base64Encoder struct{} 15 16 func (e Base64Encoder) Encode(c *Cookie) (string, error) { 17 j, err := jsonutil.Marshal(c) 18 if err != nil { 19 return "", err 20 } 21 b64 := base64.URLEncoding.EncodeToString(j) 22 23 return b64, nil 24 }