react

package
v0.0.0-...-519d24f Latest Latest
Warning

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

Go to latest
Published: May 5, 2020 License: BSD-3-Clause Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DefaultPage = Must(New())

Functions

This section is empty.

Types

type Merger

type Merger interface {
	Merge(interface{}) interface{}
}

type Page

type Page struct {
	// contains filtered or unexported fields
}

Page is a view.Page implementation for react applications. The fields in this object is used as a default values of PageVars

func Must

func Must(p *Page, e error) *Page

func New

func New(options ...PageOption) (*Page, error)

func (*Page) Configure

func (p *Page) Configure(options ...PageOption) (*Page, error)

func (*Page) Render

func (p *Page) Render(req *web.Request) *response.Response

Render implements view.Page#Render

type PageConfig

type PageConfig struct {
	ReactModulePath   string `json:"react_module_path"`
	AuthAPIBasePath   string `json:"auth_api_base_path"`
	FacebookAppID     string `json:"facebook_app_id"`
	FacebookPageID    string `json:"facebook_page_id"`
	FacebookPixelID   string `json:"facebook_pixel_id"`
	GoogleAnalyticsID string `json:"google_analytics_id"`
	TwitterID         string `json:"twitter_id"`
	InstagramID       string `json:"instagram_id"`
}

Config represents the built-in data items used in react pages configurations

func (*PageConfig) Merge

func (c *PageConfig) Merge(obj interface{}) interface{}

type PageOption

type PageOption func(p *Page) (*Page, error)

func AppData

func AppData(key string, value interface{}) PageOption

AppData returns a PageOption to set the AppData field.

func Body

func Body(b []byte) PageOption

Body returns a PageOption to add to set body

func Config

func Config(c *PageConfig) PageOption

Config returns a PageOption to set PageConfig

func Favicon

func Favicon(favicon string) PageOption

Faviconreturns a PageOption to set the favicon path

func GeneratorFunc

func GeneratorFunc(f func(req *web.Request) (*PageVars, error)) PageOption

GeneratorFunc returns a PageOption to set a *PageVar generator function

func JavaScripts

func JavaScripts(urls ...string) PageOption

JavasScripts returns a PageOption to add urls into the javascript list.

func MetaName

func MetaName(key string, value string) PageOption

MetaName returns a PageOption to set the meta name.

func MetaProperty

func MetaProperty(key string, value string) PageOption

MetaProperty returns a PageOption to set the meta props.

func Stylesheets

func Stylesheets(urls ...string) PageOption

Stylesheets returns a PageOption to add urls into the stylesheet list.

func Template

func Template(str string) PageOption

Template returns a PageOption to overwrite the default template

func Title

func Title(title string) PageOption

Title returns a PageOption to set the title

type PageVars

type PageVars struct {
	Status         response.HTTPStatus
	Title          string
	CanonicalURL   string
	Favicon        string
	Body           template.HTML
	MetaNames      map[string]string
	MetaProperties map[string]string
	CSRFToken      string
	ModulePath     string
	Config         *PageConfig
	AppData        map[string]interface{}
	Auth           interface{}
	Stylesheets    []string
	Javascripts    []string
}

PageVars is a page data generated per an http request from a Page object.

func Status

func Status(s response.HTTPStatus) *PageVars

Status returns a blank *PageVars with a status code

func (*PageVars) Merge

func (pv *PageVars) Merge(pv2 *PageVars)

type PageVarsGenerator

type PageVarsGenerator interface {
	Gen(req *web.Request) (*PageVars, error)
}

PageVarsGenerator is an interface to generate a *PageVars

type PageVarsGeneratorFunc

type PageVarsGeneratorFunc func(req *web.Request) (*PageVars, error)

PageVarsGeneratorFunc is a func to ConfigGenerator conversion

func (PageVarsGeneratorFunc) Gen

Gen implements ConfigGenerator#Fetch

Jump to

Keyboard shortcuts

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