Documentation ¶
Index ¶
- Variables
- func ErrJoin(errs []error, delim string) error
- func Get(domain string) (host string, bytes []byte, err error)
- func GetCanonicalAdSystemDomain(e string) (string, error)
- func Parse(b []byte) (rec []Record, lc []LineComment, va []Variable, el []ErrorLine, e error)
- func Read(resp *http.Response) ([]byte, error)
- func Request(domain string) (*http.Response, error)
- func SetCanonicalMaps(filename string) error
- type AdsystemMap
- type Domain
- type ErrorLine
- type File
- type LineComment
- type PublisherAccountType
- type Record
- type Variable
Constants ¶
This section is empty.
Variables ¶
View Source
var Client = http.Client{ CheckRedirect: func(req *http.Request, via []*http.Request) error { if len(via) > 1 { hosts := make(map[string]struct{}) hosts[strings.Replace(req.URL.Host, "www.", "", 1)] = struct{}{} for _, r := range via { hosts[strings.Replace(r.URL.Host, "www.", "", 1)] = struct{}{} } if len(hosts) > 2 { return fmt.Errorf("illegal redirect chain. %s", hosts) } } return nil }, Timeout: time.Second * 10, }
Functions ¶
func SetCanonicalMaps ¶
Types ¶
type AdsystemMap ¶
type Domain ¶
type Domain struct { Host string // sub2.sub1.test.co.jp Root string // test.co.jp PublicSuffix string // co.jp ICANN bool // see PublicSuffix comments Subs []string // [ "sub2" "sub1" ] most specific first }
func DomainFromString ¶
This supports sub2.sub1.root.com format. Data not in this format should in URL format should use Should use url.Parse and then DomainFromURL
func (*Domain) ListDomains ¶
type File ¶
type File struct { // The URL location of this adstxt URL string `json:"url"` // The Root Domain RootDomain string `json:"root_domain"` // The Subdomain of the Root Domain the adstxt is valid for AdstxtDomain string `json:"adstxt_domain"` // Valid Exchange/PubID combinations/routes for a certain publishers bid requests Records []Record `json:"adpaths"` // Comments that occupy a full line LineComments []LineComment `json:"line_comments,omitempty"` // Any line containing a pattern of <VARIABLE>=<VALUE> should be interpreted as a variable // declaration. Variables []Variable `json:"variables,omitempty"` // ErrLines []ErrorLine // SHA256 checksum of the bytes in the response body CheckSum string `json:"checksum"` // The time of the adstxt get request LookupTime time.Time `json:"lookup_time"` }
func (*File) IsValidSubDomain ¶
type LineComment ¶
type PublisherAccountType ¶
type PublisherAccountType int
const ( NO_ACCOUNT_TYPE_SPECIFIED PublisherAccountType = iota DIRECT RESELLER BOTH // some ads.txt file contain duplicate rows for the same pubid with reseller and direct types. these can be reduced by calling DedupOnAccountType() INVALID_ACCOUNT_TYPE )
func GetAccountType ¶
func GetAccountType(s string) PublisherAccountType
func (PublisherAccountType) MarshalJSON ¶
func (p PublisherAccountType) MarshalJSON() ([]byte, error)
func (PublisherAccountType) String ¶
func (p PublisherAccountType) String() string
type Record ¶
type Record struct { // (Required) The canonical domain name of the SSP, Exchange, Header Wrapper, etc system that // bidders connect to. This may be the operational domain of the system, if that is different than the // parent corporate domain, to facilitate WHOIS and reverse IP lookups to establish clear ownership of // the delegate system. Ideally the SSP or Exchange publishes a document detailing what domain name // to use. AdSystemDomain string `json:"ad_system_domain"` // This field is an attempt to reconcile different ad system domains that mean the same thing. Matching // adstxt data with bid request data requires a mapping, but because many adstxt files say the same thing // different this field attempts to canonize a specific ad system spelling see disambiguation.go CanonicalSystemDomain string `json:"canonical_system_domain"` // (Required) The identifier associated with the seller or reseller account within the advertising system in // field #1. This must contain the same value used in transactions (i.e. OpenRTB bid requests) in the // field specified by the SSP/exchange. Typically, in OpenRTB, this is publisher.id. For OpenDirect it is // typically the publisher’s organization ID. ExDomain. PublisherID string `json:"publisher_id"` // (Required) An enumeration of the type of account. A value of ‘DIRECT’ indicates that the Publisher // (content owner) directly controls the account indicated in field #2 on the system in field #1. This // tends to mean a direct business contract between the Publisher and the advertising system. A value // of ‘RESELLER’ indicates that the Publisher has authorized another entity to control the account // indicated in field #2 and resell their ad space via the system in field #1. Other types may be added // in the future. Note that this field should be treated as case insensitive when interpreting the data. AccountType PublisherAccountType `json:"account_type"` // (Optional) An ID that uniquely identifies the advertising system within a certification authority // (this ID maps to the entity listed in field #1). A current certification authority is the Trustworthy // Accountability Group (aka TAG), and the TAGID would be included here. CertAuthorityID string `json:"cert_authority_id,omitempty"` // Extension fields are allowed by implementers and their consumers as long as they utilize a // distinct final separator field ";" before adding extension data to each record Ext []string `json:"ext,omitempty"` // Anything after # on a line is considered to be a comment Comment string `json:"comment,omitempty"` // The line number the record was found on, after removing empty lines. This is useful for // attaching line comment information to records. LineNum int `json:"line_num"` }
func ParseRecord ¶
Click to show internal directories.
Click to hide internal directories.