webui

package
v3.24.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 2, 2023 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CleanCSP added in v3.15.2

func CleanCSP(csp map[string][]string) map[string][]string

CleanCSP de-duplicates and removes empty entries from the CSP directive map.

func GenerateCSPString added in v3.15.2

func GenerateCSPString(csp map[string][]string) string

GenerateCSPNonce returns a final csp string from map of directives.

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

func WithAppConfig(r *http.Request, cfg interface{}) *http.Request

WithAppConfig constructs a *http.Request which has the provided app config attached.

func WithNonce added in v3.16.2

func WithNonce(r *http.Request) (*http.Request, string)

WithNonce constructs a *http.Request which has a nonce attached.

func WithPageData added in v3.16.2

func WithPageData(r *http.Request, pageData interface{}) *http.Request

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

func (c APIConfig) MarshalJSON() ([]byte, error)

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 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.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL