forked from prebid/prebid-server
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmacros.go
34 lines (29 loc) · 751 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
package macros
import (
"bytes"
"text/template"
)
// EndpointTemplateParams specifies params for an endpoint template
type EndpointTemplateParams struct {
Host string
PublisherID string
ZoneID string
SourceId string
AccountID string
}
// UserSyncTemplateParams specifies params for an user sync URL template
type UserSyncTemplateParams struct {
GDPR string
GDPRConsent string
USPrivacy string
}
// ResolveMacros resolves macros in the given template with the provided params
func ResolveMacros(aTemplate template.Template, params interface{}) (string, error) {
strBuf := bytes.Buffer{}
err := aTemplate.Execute(&strBuf, params)
if err != nil {
return "", err
}
res := strBuf.String()
return res, nil
}