github.com/prebid/prebid-server/v2@v2.18.0/macros/macros.go (about)

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