Documentation ¶
Index ¶
- Variables
- func DelContext(p Page, key string)
- func GetContext(p Page, key string) interface{}
- func InsightsID(p interface{}) string
- func InsightsName(p interface{}) string
- func PageHandler(p Page) http.HandlerFunc
- func Redirect(rp *RedirectParameters)
- func RenderPage(w io.Writer, p Page)
- func RenderSSA(w io.Writer, dp *DummyPage, p SSAParameters)
- func SSAFlush(p Page, c Component)
- func SSAHandler(tb TemplateBuilder) http.HandlerFunc
- func SetContext(p Page, key string, value interface{})
- func TAction(action string, args ...interface{}) template.JS
- func TBind(field string) template.JS
- func TComponentAttrs(c Component) template.HTMLAttr
- func TDynamics(path ...string) template.HTML
- func TFormSubmit() template.JS
- func TFuncMap() template.FuncMap
- func TJSON(data interface{}) string
- func TMeta(p Page) template.HTML
- func TRender(c Component) string
- type Action
- type ActionMap
- type Component
- type DummyPage
- type Hreflang
- type ImplementsActions
- type ImplementsActionsWithoutPage
- type ImplementsAfterAsync
- type ImplementsAfterAsyncWithoutPage
- type ImplementsAsync
- type ImplementsAsyncWithoutPage
- type ImplementsInit
- type ImplementsInitWithoutPage
- type ImplementsMeta
- type ImplementsRender
- type ImplementsTemplate
- type ImplementsTemplateWithoutPage
- type Insights
- type InsightsTiming
- type Meta
- type Page
- type RedirectParameters
- type SSAParameters
- type TemplateBuilder
Constants ¶
This section is empty.
Variables ¶
var ( // INSIGHTS config boolean INSIGHTS = false // INSIGHTS_CLI config boolean INSIGHTS_CLI = false // INSIGHTS_CLI_JSON output insights in json format INSIGHTS_CLI_JSON = false // INSIGHTS_LIMIT limit of insights INSIGHTS_LIMIT = 10 )
var ( // OnError is an error processing function. // Panic by default OnError = func(p Page, err error) { panic(err) } )
var RegC = RegisterComponent
RegC is an alias for RegisterComponent
Functions ¶
func DelContext ¶
DelContext delete the page's context data by key
func GetContext ¶
GetContext of the specified page, return data stored by key
func InsightsID ¶
func InsightsID(p interface{}) string
InsightsID is a function to generate ID from pointer
func InsightsName ¶
func InsightsName(p interface{}) string
InsightsName is a function that extracts type name from pointer
func PageHandler ¶
func PageHandler(p Page) http.HandlerFunc
PageHandler is an opinionated page net/http handler. Context: - internal:rw - http.ResponseWriter - internal:r - *http.Request
func Redirect ¶
func Redirect(rp *RedirectParameters)
Redirect is a wrapper around http.Redirect for correct work inside of SSC
func RenderPage ¶
RenderPage is a main entrypoint of rendering. Responsible for rendering and components lifecycle
func RenderSSA ¶
func RenderSSA(w io.Writer, dp *DummyPage, p SSAParameters)
RenderSSA is a low-level component rendering function for SSA. Responsible for rendering and components SSA lifecycle
func SSAFlush ¶
SSAFlush is a low-level function for rendering and flushing component UI to the client
func SSAHandler ¶
func SSAHandler(tb TemplateBuilder) http.HandlerFunc
SSAHandler is an opinionated SSA net/http handler. Context: - internal:rw - http.ResponseWriter - internal:r - *http.Request
func SetContext ¶
SetContext of a page, page based key value store using a string as a key and an interface to store the data
func TComponentAttrs ¶
func TFormSubmit ¶
Types ¶
type Action ¶
type Action func(args ...interface{})
Action is used to pass arguments onto a component to be used
type Component ¶
type Component interface{}
Component contains only must-have methods
func RegisterComponent ¶
RegisterComponent is used while defining components in the Init() section
type DummyPage ¶
type DummyPage struct {
TemplateBuilder TemplateBuilder
}
DummyPage is an SSA page placeholder
type ImplementsActions ¶
ImplementsActions interface for implementing actions
type ImplementsActionsWithoutPage ¶
type ImplementsActionsWithoutPage interface {
Actions() ActionMap
}
ImplementsActionsWithoutPage interface type
type ImplementsAfterAsync ¶
type ImplementsAfterAsync interface {
AfterAsync(Page)
}
ImplementsAfterAsync interface for after asynchronous functions
type ImplementsAfterAsyncWithoutPage ¶
type ImplementsAfterAsyncWithoutPage interface {
AfterAsync()
}
ImplementsAfterAsyncWithoutPage interface type
type ImplementsAsync ¶
ImplementsAsync interface for asynchronous functions
type ImplementsAsyncWithoutPage ¶
type ImplementsAsyncWithoutPage interface {
Async() error
}
ImplementsAsyncWithoutPage interface for Asynchronous functions without a page
type ImplementsInit ¶
type ImplementsInit interface {
Init(Page)
}
ImplementsInit interface for implementing init
type ImplementsInitWithoutPage ¶
type ImplementsInitWithoutPage interface {
Init()
}
ImplementsInitWithoutPage interface type
type ImplementsRender ¶ added in v0.1.2
type ImplementsRender interface {
Render() string
}
type ImplementsTemplate ¶ added in v0.1.2
type ImplementsTemplateWithoutPage ¶ added in v0.1.2
type Insights ¶
type Insights struct { InsightsTiming ID string `json:"id"` Name string `json:"name"` Nested []*Insights `json:"nested"` }
Insights data type
func GetInsights ¶
func GetInsights(p interface{}) *Insights
GetInsights returns insights pointer by given object pointer
func GetInsightsByID ¶
GetInsightsByID returns insights pointer by insights id
func NewInsights ¶
func NewInsights(p interface{}) *Insights
NewInsights creates new insights instance for provided object pointer, saves insights pointer to local store and returns it The oldest insights are cut in case of store overflow (INSIGHTS_LIMIT config)
func (*Insights) GetOrCreateNested ¶
GetOrCreateNested attempts to return existing nested insights, or returns new ones
type InsightsTiming ¶
type InsightsTiming struct { Init time.Duration `json:"i"` Async time.Duration `json:"a"` AfterAsync time.Duration `json:"aa"` Render time.Duration `json:"r"` }
InsightsTiming data type
type Meta ¶
type Meta struct { Title string Description string Canonical string Hreflangs []Hreflang Additional []map[string]string }
Meta data
type RedirectParameters ¶
type RedirectParameters struct { Page Page ResponseWriter http.ResponseWriter Request *http.Request ResponseWriterKey string RequestKey string Target string StatusCode int }
RedirectParameters is a helper for the Redirect function
type SSAParameters ¶
type SSAParameters struct { Component string Action string State string // JSON string Args string // JSON string }
SSAParameters represents parameters, needed for handling SSA request
type TemplateBuilder ¶
TemplateBuilder is used to build templates.