-
Notifications
You must be signed in to change notification settings - Fork 700
/
macros.go
41 lines (35 loc) · 906 Bytes
/
macros.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
package macros
import (
"bytes"
"text/template"
)
// EndpointTemplateParams specifies macros for bidder endpoints.
type EndpointTemplateParams struct {
Host string
PublisherID string
ZoneID string
SourceId string
AccountID string
AdUnit string
MediaType string
GvlID string
PageID string
SupplyId string
}
// UserSyncPrivacy specifies privacy policy macros, represented as strings, for user sync urls.
type UserSyncPrivacy struct {
GDPR string
GDPRConsent string
USPrivacy string
GPP string
GPPSID string
}
// ResolveMacros resolves macros in the given template with the provided params
func ResolveMacros(aTemplate *template.Template, params interface{}) (string, error) {
strBuf := bytes.Buffer{}
if err := aTemplate.Execute(&strBuf, params); err != nil {
return "", err
}
res := strBuf.String()
return res, nil
}