Documentation ¶
Index ¶
- func GenerateNonce() string
- func RegisterHashedFile(original, hashed string)
- func WithAppConfig(r *http.Request, cfg interface{}) *http.Request
- func WithNonce(r *http.Request) (*http.Request, string)
- func WithPageData(r *http.Request, pageData interface{}) *http.Request
- func WithTemplateData(r *http.Request, data TemplateData) *http.Request
- type APIConfig
- type AppTemplate
- type ContentSecurityPolicy
- type Data
- type TemplateData
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GenerateNonce ¶ added in v3.15.2
func GenerateNonce() string
GenerateNonce returns a nonce used for inline scripts.
func RegisterHashedFile ¶
func RegisterHashedFile(original, hashed string)
RegisterHashedFile maps filenames to webpack generated hashed filenames
func WithAppConfig ¶ added in v3.16.2
WithAppConfig constructs a *http.Request which has the provided app config attached.
func WithPageData ¶ added in v3.16.2
WithPageData constructs a *http.Request which has the provided page data attached.
func WithTemplateData ¶ added in v3.16.2
func WithTemplateData(r *http.Request, data TemplateData) *http.Request
WithTemplateData constructs a *http.Request which has the provided TemplateData attached.
Types ¶
type APIConfig ¶
type APIConfig struct { Enabled bool `json:"enabled" name:"enabled" description:"Enable this API"` BaseURL string `json:"base_url" name:"base-url" description:"Base URL to the HTTP API"` }
APIConfig for upstream APIs.
func (APIConfig) MarshalJSON ¶
MarshalJSON implements json.Marshaler.
type AppTemplate ¶
type AppTemplate struct {
// contains filtered or unexported fields
}
AppTemplate wraps the application template for the web UI.
var Template *AppTemplate
Template for rendering the web UI. The context is expected to contain TemplateData as "template_data". The "app_config" will be rendered into the environment.
func NewAppTemplate ¶
func NewAppTemplate(t *template.Template) *AppTemplate
NewAppTemplate instantiates a new application template for the web UI.
func (*AppTemplate) ServeHTTP ¶ added in v3.16.2
func (t *AppTemplate) ServeHTTP(w http.ResponseWriter, r *http.Request)
ServeHTTP renders the web UI.
type ContentSecurityPolicy ¶ added in v3.25.1
type ContentSecurityPolicy struct { ConnectionSource []string StyleSource []string ScriptSource []string BaseURI []string FrameAncestors []string }
ContentSecurityPolicy contains the Content Security Policy.
func (ContentSecurityPolicy) Clean ¶ added in v3.25.1
func (csp ContentSecurityPolicy) Clean() ContentSecurityPolicy
Clean de-duplicates and removes empty entries from the policy.
func (ContentSecurityPolicy) Merge ¶ added in v3.25.1
func (csp ContentSecurityPolicy) Merge(others ...ContentSecurityPolicy) ContentSecurityPolicy
Merge merges the provided policies into the existing one.
func (ContentSecurityPolicy) String ¶ added in v3.25.1
func (csp ContentSecurityPolicy) String() string
String returns the policy in string form.
type Data ¶
type Data struct { TemplateData AppConfig interface{} ExperimentalFeatures map[string]bool PageData interface{} CSPNonce string }
Data contains data to render templates.
type TemplateData ¶
type TemplateData struct { SiteName string `name:"site-name" description:"The site name"` Title string `name:"title" description:"The page title"` SubTitle string `name:"sub-title" description:"The page sub-title"` Description string `name:"descriptions" description:"The page description"` Language string `name:"language" description:"The page language"` ThemeColor string `name:"theme-color" description:"The page theme color"` CanonicalURL string `name:"canonical-url" description:"The page canonical URL"` AssetsBaseURL string `name:"assets-base-url" description:"The base URL to the page assets"` BrandingBaseURL string `name:"branding-base-url" description:"The base URL to the branding assets"` IconPrefix string `name:"icon-prefix" description:"The prefix to put before the page icons (favicon.ico, touch-icon.png, og-image.png)"` CSSFiles []string `name:"css-file" description:"The names of the CSS files"` JSFiles []string `name:"js-file" description:"The names of the JS files"` SentryDSN string `name:"sentry-dsn" description:"The Sentry DSN"` CSRFToken string `name:"-"` }
TemplateData contains data to use in the App template.
func (TemplateData) MountPath ¶
func (t TemplateData) MountPath() string
MountPath derives the mount path from the canonical URL of the config.