Documentation
¶
Index ¶
- func AsPrintable(p *swan.Pair) string
- func AsString(p *swan.Pair) string
- func AsStringFromUUID(p *swan.Pair) string
- func GetCleanURL(c *Configuration, r *http.Request) *url.URL
- func GetConfigFile(folder string) *os.File
- func GetCurrentPage(c *Configuration, r *http.Request) *url.URL
- func GetReturnURL(r *http.Request) (*url.URL, error)
- func GetSWANDataFromRequest(r *http.Request) string
- func Handler(d []*Domain) http.HandlerFunc
- func HandlerHTML(d *Domain, w http.ResponseWriter, r *http.Request)
- func NewError(c *Configuration, r *http.Response) *swan.Error
- func OWIDDate(p *swan.Pair) string
- func OWIDDomain(p *swan.Pair) string
- func ReturnProxyError(c *Configuration, w http.ResponseWriter, e *swan.Error)
- func ReturnServerError(c *Configuration, w http.ResponseWriter, err error)
- func ReturnStatusCodeError(c *Configuration, w http.ResponseWriter, e error, code int)
- type Advert
- type Configuration
- type Domain
- type PageModel
- type SMTP
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AsPrintable ¶
func AsPrintable(p *swan.Pair) string
AsPrintable gets the value of the pair as a printable string for display.
func AsString ¶
func AsString(p *swan.Pair) string
AsString gets the value of the pair as string for display.
func AsStringFromUUID ¶
func AsStringFromUUID(p *swan.Pair) string
func GetCleanURL ¶
func GetCleanURL(c *Configuration, r *http.Request) *url.URL
GetCleanURL returns a URL with the SWAN data removed and no query string parameters.
func GetConfigFile ¶
GetConfig returns the configuration from the folder, or nil if the configuration does not exist.
func GetCurrentPage ¶
func GetCurrentPage(c *Configuration, r *http.Request) *url.URL
GetCurrentPage returns the current request URL.
func GetReturnURL ¶
GetReturnURL returns a parsed URL from the query string, or if not present from the referer HTTP header.
func GetSWANDataFromRequest ¶
GetSWANDataFromRequest returns the base 64 SWAN data from the request if present, otherwise an empty string.
func Handler ¶
func Handler(d []*Domain) http.HandlerFunc
Handler for all HTTP requests to domains controlled by the demo.
func HandlerHTML ¶
func HandlerHTML(d *Domain, w http.ResponseWriter, r *http.Request)
HandlerHTML returns HTML that does not require a model for the template.
func NewError ¶
func NewError(c *Configuration, r *http.Response) *swan.Error
NewError creates an error instance that includes the details of the response returned. This is needed to pass the correct status codes and context back to the caller.
func OWIDDomain ¶
func OWIDDomain(p *swan.Pair) string
OWIDDomain returns the creator domain of the ID.
func ReturnProxyError ¶
func ReturnProxyError(c *Configuration, w http.ResponseWriter, e *swan.Error)
ReturnProxyError returns an error where the request is related to a proxy request being passed to another end point.
func ReturnServerError ¶
func ReturnServerError(c *Configuration, w http.ResponseWriter, err error)
ReturnServerError returns an internal server error.
func ReturnStatusCodeError ¶
func ReturnStatusCodeError( c *Configuration, w http.ResponseWriter, e error, code int)
ReturnStatusCodeError returns the HTTP status code specified.
Types ¶
type Advert ¶
type Advert struct { MediaURL string // The URL of the content of the advert provided in response AdvertiserURL string // The URL to direct the browser to if the advert is selected }
Advert represents an advert to display on a publishers web page.
type Configuration ¶
type Configuration struct { AccessKeys []string `json:"accessKeys"` // Array of valid keys for SWAN access Scheme string `json:"scheme"` // The scheme to use for requests Debug bool `json:"debug"` // True if debug HTML output should be provided Domains []*Domain // All the domains that form the demo // contains filtered or unexported fields }
Configuration maps to the appsettings.json settings file.
func NewConfig ¶
func NewConfig(settingsFile string) Configuration
NewConfig creates a new instance of configuration from the file provided.
type Domain ¶
type Domain struct { Category string // Category of the domain Name string // Common name for the domain Bad bool // True if this domain is a bad actor for the demo Host string // The host name for the domain SwanMessage string // Message if used with SWAN SwanBackgroundColor string // Background color if used with SWAN SwanMessageColor string // Message text color if used with SWAN SwanProgressColor string // Message progress color if used with SWAN SwanPostMessage bool // True if the publisher gets the results from SWAN as a post message SwanDisplayUserInterface bool // True to display the user interface SwanUseHomeNode bool // True to use the home node if it has current data SwanJavaScript bool // True to use JavaScript responses rather than HTML documents SwanNodeCount int // The number of SWAN nodes to use for operations CmpNodeCount int // The number of nodes to visit when accessing the CMP Default bool // True to indicate the default domain // The domain of the access node used with SWAN (only set for CMPs) SWANAccessNode string SWANAccessKey string // The access key to use when communicating with SWAN. // The domain of the CMP that will in turn access the SWAN Network via an Operator CMP string Suppliers []string // Suppliers used by the domain operator Adverts []Advert // Adverts the domain can serve Config *Configuration // Configuration for the server // contains filtered or unexported fields }
Domain represents the information held in the domain configuration file commonly represented in the demo in config.json.
func (*Domain) GetOWIDCreator ¶
GetOWIDCreator returns the OWID creator from the OWID store for the the domain.
func (*Domain) LookupHTML ¶
LookupHTML based on the templates available to the domain.
func (*Domain) SetHandler ¶
SetHandler adds a HTTP handler to the domain.
type PageModel ¶
type PageModel struct { Domain *Domain // The domain associated with the request // The request that relates to the page request with the ParseForm method complete Request *http.Request }
PageModel used as the base for models used with HTML templates.
func (PageModel) Config ¶
func (m PageModel) Config() *Configuration
Config returns the domain configuration.
func (PageModel) HttpHeaders ¶
HttpHeaders available in the request.
func (PageModel) PreferencesDialogURL ¶
PreferencesDialogURL returns the URL to display the preferences dialog.
func (PageModel) SupportsHTTPS ¶
SupportsHTTPS returns true if the server supports HTTPS.