web

package module
v1.3.2 Latest Latest
Warning

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

Go to latest
Published: Dec 5, 2023 License: MIT Imports: 16 Imported by: 79

README

Documentation

https://docs.qor5.com

Documentation

Index

Constants

View Source
const EventFuncIDName = "__execute_event__"
View Source
const InitContextLocals = "v-init-context:locals"
View Source
const InitContextVars = "v-init-context:vars"

Variables

View Source
var Default = New()

Functions

func AppendVarsScripts

func AppendVarsScripts(er *EventResponse, scripts ...string)

func GlobalEvents

func GlobalEvents() *h.HTMLTagBuilder

func NoopLayoutFunc

func NoopLayoutFunc(r *http.Request, injector *PageInjector, body string) (output string, err error)

func PacksHandler

func PacksHandler(contentType string, packs ...ComponentsPack) http.Handler

func VFieldName

func VFieldName(v string, opts ...VFieldNameOption) []interface{}

func WrapEventContext

func WrapEventContext(parent context.Context, ctx *EventContext) (r context.Context)

Types

type Builder

type Builder struct {
	EventsHub
	// contains filtered or unexported fields
}

func New

func New() (b *Builder)

func (*Builder) EventFuncs

func (p *Builder) EventFuncs(vs ...interface{}) (r *Builder)

func (*Builder) LayoutFunc

func (b *Builder) LayoutFunc(mf LayoutFunc) (r *Builder)

func (*Builder) PacksHandler

func (b *Builder) PacksHandler(contentType string, packs ...ComponentsPack) http.Handler

func (*Builder) Page

func (b *Builder) Page(pf PageFunc) (p *PageBuilder)

type ComponentsPack

type ComponentsPack string

func JSComponentsPack

func JSComponentsPack() ComponentsPack

func JSVueComponentsPack

func JSVueComponentsPack() ComponentsPack

type EventContext

type EventContext struct {
	R        *http.Request
	W        http.ResponseWriter
	Injector *PageInjector
	Flash    interface{} // pass value from actions to index
}

func MustGetEventContext

func MustGetEventContext(c context.Context) (r *EventContext)

func (*EventContext) MustUnmarshalForm

func (ctx *EventContext) MustUnmarshalForm(v interface{})

func (*EventContext) Queries

func (e *EventContext) Queries() (r url.Values)

func (*EventContext) QueryAsInt

func (e *EventContext) QueryAsInt(key string) (r int)

func (*EventContext) UnmarshalForm

func (ctx *EventContext) UnmarshalForm(v interface{}) (err error)

type EventFunc

type EventFunc func(ctx *EventContext) (r EventResponse, err error)

type EventFuncHub

type EventFuncHub interface {
	RegisterEventFunc(eventFuncId string, ef EventFunc) (key string)
}

@snippet_begin(EventFuncHubDefinition)

type EventFuncID

type EventFuncID struct {
	ID string `json:"id,omitempty"`
}

type EventResponse

type EventResponse struct {
	PageTitle     string           `json:"pageTitle,omitempty"`
	Body          h.HTMLComponent  `json:"body,omitempty"`
	Reload        bool             `json:"reload,omitempty"`
	PushState     *LocationBuilder `json:"pushState"`             // This we don't omitempty, So that {} can be kept when use url.Values{}
	RedirectURL   string           `json:"redirectURL,omitempty"` // change window url without push state
	ReloadPortals []string         `json:"reloadPortals,omitempty"`
	UpdatePortals []*PortalUpdate  `json:"updatePortals,omitempty"`
	Data          interface{}      `json:"data,omitempty"`       // used for return collection data like TagsInput data source
	VarsScript    string           `json:"varsScript,omitempty"` // used with InitContextVars to set values for example vars.show to used by v-model
}

@snippet_begin(EventResponseDefinition)

type EventsHub

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

func (*EventsHub) RegisterEventFunc

func (p *EventsHub) RegisterEventFunc(eventFuncId string, ef EventFunc) (key string)

type LayoutFunc

type LayoutFunc func(r *http.Request, injector *PageInjector, body string) (output string, err error)

type LocationBuilder

type LocationBuilder struct {
	MyMergeQuery          bool                      `json:"mergeQuery,omitempty"`
	MyURL                 string                    `json:"url,omitempty"`
	MyStringQuery         string                    `json:"stringQuery,omitempty"`
	MyClearMergeQueryKeys []string                  `json:"clearMergeQueryKeys,omitempty"`
	MyQuery               map[string]json.Marshaler `json:"query,omitempty"`
}

LocationBuilder mapping to type.ts Location interface

func Location

func Location(query url.Values) (r *LocationBuilder)

func (*LocationBuilder) ClearMergeQuery

func (b *LocationBuilder) ClearMergeQuery(clearKeys []string) (r *LocationBuilder)

func (*LocationBuilder) MergeQuery

func (b *LocationBuilder) MergeQuery(v bool) (r *LocationBuilder)

func (*LocationBuilder) MergeWithAppend

func (b *LocationBuilder) MergeWithAppend(key string, values []string) (r *LocationBuilder)

func (*LocationBuilder) MergeWithRemove

func (b *LocationBuilder) MergeWithRemove(key string, values []string) (r *LocationBuilder)

func (*LocationBuilder) PutQuery

func (b *LocationBuilder) PutQuery(key string, values []string) (r *LocationBuilder)

func (*LocationBuilder) Query

func (b *LocationBuilder) Query(query url.Values) (r *LocationBuilder)

func (*LocationBuilder) StringQuery

func (b *LocationBuilder) StringQuery(v string) (r *LocationBuilder)

func (*LocationBuilder) URL

func (b *LocationBuilder) URL(url string) (r *LocationBuilder)

type MetaKey

type MetaKey string

type PageBuilder

type PageBuilder struct {
	EventsHub
	// contains filtered or unexported fields
}

func Page

func Page(pf PageFunc, efs ...interface{}) (p *PageBuilder)

func (*PageBuilder) Builder

func (p *PageBuilder) Builder(v *Builder) (r *PageBuilder)

func (*PageBuilder) EventFunc

func (p *PageBuilder) EventFunc(name string, ef EventFunc) (r *PageBuilder)

func (*PageBuilder) EventFuncs

func (p *PageBuilder) EventFuncs(vs ...interface{}) (r *PageBuilder)

func (*PageBuilder) MaxFormSize

func (p *PageBuilder) MaxFormSize(v int64) (r *PageBuilder)

func (*PageBuilder) MergeHub

func (p *PageBuilder) MergeHub(hub *EventsHub) (r *PageBuilder)

func (*PageBuilder) ServeHTTP

func (p *PageBuilder) ServeHTTP(w http.ResponseWriter, r *http.Request)

func (*PageBuilder) Wrap

func (p *PageBuilder) Wrap(middlewares ...func(in PageFunc) PageFunc) (r *PageBuilder)

type PageFunc

type PageFunc func(ctx *EventContext) (r PageResponse, err error)

@snippet_begin(PageFuncAndEventFuncDefinition)

type PageInjector

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

func Injector

func Injector(c context.Context) (r *PageInjector)

func (*PageInjector) Clear

func (b *PageInjector) Clear() (r *PageInjector)

func (*PageInjector) GetExtraHTMLComponent

func (b *PageInjector) GetExtraHTMLComponent() h.HTMLComponent

func (*PageInjector) GetHTMLLang

func (b *PageInjector) GetHTMLLang() string

func (*PageInjector) GetHeadHTMLComponent

func (b *PageInjector) GetHeadHTMLComponent() h.HTMLComponent

func (*PageInjector) GetTailHTMLComponent

func (b *PageInjector) GetTailHTMLComponent() h.HTMLComponent

func (*PageInjector) HTMLLang

func (b *PageInjector) HTMLLang(lang string)

func (*PageInjector) HasTitle

func (b *PageInjector) HasTitle() (r bool)

func (*PageInjector) HeadHTML

func (b *PageInjector) HeadHTML(v string)

func (*PageInjector) HeadHTMLComponent

func (b *PageInjector) HeadHTMLComponent(key interface{}, comp h.HTMLComponent, replace bool)

func (*PageInjector) Meta

func (b *PageInjector) Meta(key interface{}, attrs ...string)

func (*PageInjector) MetaNameContent

func (b *PageInjector) MetaNameContent(name, content string)

func (*PageInjector) SkipDefaultSetting

func (b *PageInjector) SkipDefaultSetting()

SkipDefaultSetting skips the setting of default nodes

func (*PageInjector) TailHTML

func (b *PageInjector) TailHTML(v string)

func (*PageInjector) TailHTMLComponent

func (b *PageInjector) TailHTMLComponent(key interface{}, comp h.HTMLComponent, replace bool)

func (*PageInjector) Title

func (b *PageInjector) Title(title string)

type PageResponse

type PageResponse struct {
	PageTitle string
	Body      h.HTMLComponent
}

type PortalBuilder

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

func Portal

func Portal(children ...h.HTMLComponent) (r *PortalBuilder)

func (*PortalBuilder) AutoReloadInterval

func (b *PortalBuilder) AutoReloadInterval(v interface{}) (r *PortalBuilder)

func (*PortalBuilder) Children

func (b *PortalBuilder) Children(comps ...h.HTMLComponent) (r *PortalBuilder)

func (*PortalBuilder) Form

func (b *PortalBuilder) Form(v string) (r *PortalBuilder)

func (*PortalBuilder) LoadWhenParentVisible

func (b *PortalBuilder) LoadWhenParentVisible() (r *PortalBuilder)

func (*PortalBuilder) Loader

func (b *PortalBuilder) Loader(v *VueEventTagBuilder) (r *PortalBuilder)

func (*PortalBuilder) MarshalHTML

func (b *PortalBuilder) MarshalHTML(ctx context.Context) (r []byte, err error)

func (*PortalBuilder) Name

func (b *PortalBuilder) Name(v string) (r *PortalBuilder)

func (*PortalBuilder) ParentForceUpdateAfterLoaded

func (b *PortalBuilder) ParentForceUpdateAfterLoaded() (r *PortalBuilder)

func (*PortalBuilder) Visible

func (b *PortalBuilder) Visible(v string) (r *PortalBuilder)

type PortalUpdate

type PortalUpdate struct {
	Name string          `json:"name,omitempty"`
	Body h.HTMLComponent `json:"body,omitempty"`
}

type ScopeBuilder

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

func Scope

func Scope(children ...h.HTMLComponent) (r *ScopeBuilder)

func (*ScopeBuilder) Init

func (b *ScopeBuilder) Init(v string) (r *ScopeBuilder)

func (*ScopeBuilder) MarshalHTML

func (b *ScopeBuilder) MarshalHTML(ctx context.Context) (r []byte, err error)

func (*ScopeBuilder) VSlot

func (b *ScopeBuilder) VSlot(v string) (r *ScopeBuilder)

type SlotBuilder

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

func Slot

func Slot(children ...h.HTMLComponent) (r *SlotBuilder)

func (*SlotBuilder) MarshalHTML

func (b *SlotBuilder) MarshalHTML(ctx context.Context) (r []byte, err error)

func (*SlotBuilder) Name

func (b *SlotBuilder) Name(v string) (r *SlotBuilder)

func (*SlotBuilder) Scope

func (b *SlotBuilder) Scope(v string) (r *SlotBuilder)

type UseForm

type UseForm string

type VFieldNameOption

type VFieldNameOption interface {
	// contains filtered or unexported methods
}

type ValidationErrors

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

func (*ValidationErrors) Error

func (b *ValidationErrors) Error() string

func (*ValidationErrors) FieldError

func (b *ValidationErrors) FieldError(fieldName string, message string)

func (*ValidationErrors) GetFieldErrors

func (b *ValidationErrors) GetFieldErrors(fieldName string) (r []string)

func (*ValidationErrors) GetGlobalError

func (b *ValidationErrors) GetGlobalError() (r string)

func (*ValidationErrors) GetGlobalErrors

func (b *ValidationErrors) GetGlobalErrors() (r []string)

func (*ValidationErrors) GlobalError

func (b *ValidationErrors) GlobalError(message string)

func (*ValidationErrors) HaveErrors

func (b *ValidationErrors) HaveErrors() bool

type Var

type Var string

type VueEventTagBuilder

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

func GET

func GET() (r *VueEventTagBuilder)

func POST

func POST() (r *VueEventTagBuilder)

func Plaid

func Plaid() (r *VueEventTagBuilder)

func (*VueEventTagBuilder) AfterScript

func (b *VueEventTagBuilder) AfterScript(script string) (r *VueEventTagBuilder)

func (*VueEventTagBuilder) BeforeScript

func (b *VueEventTagBuilder) BeforeScript(script string) (r *VueEventTagBuilder)

func (*VueEventTagBuilder) ClearMergeQuery

func (b *VueEventTagBuilder) ClearMergeQuery(v interface{}) (r *VueEventTagBuilder)

ClearMergeQuery param v use interface{} because you can not only pass []string, but also pass in javascript variables by using web.Var("$event")

func (*VueEventTagBuilder) EventFunc

func (b *VueEventTagBuilder) EventFunc(id interface{}) (r *VueEventTagBuilder)

func (*VueEventTagBuilder) FieldValue

func (b *VueEventTagBuilder) FieldValue(name interface{}, v interface{}) (r *VueEventTagBuilder)

func (*VueEventTagBuilder) Form

func (b *VueEventTagBuilder) Form(v interface{}) (r *VueEventTagBuilder)

func (*VueEventTagBuilder) FormClear

func (b *VueEventTagBuilder) FormClear() (r *VueEventTagBuilder)

func (*VueEventTagBuilder) Go

func (b *VueEventTagBuilder) Go() (r string)

func (*VueEventTagBuilder) Location

func (*VueEventTagBuilder) MarshalJSON

func (b *VueEventTagBuilder) MarshalJSON() ([]byte, error)

func (*VueEventTagBuilder) MergeQuery

func (b *VueEventTagBuilder) MergeQuery(v interface{}) (r *VueEventTagBuilder)

func (*VueEventTagBuilder) Method

func (b *VueEventTagBuilder) Method(v interface{}) (r *VueEventTagBuilder)

func (*VueEventTagBuilder) PopState

func (b *VueEventTagBuilder) PopState(v interface{}) (r *VueEventTagBuilder)

func (*VueEventTagBuilder) PushState

func (b *VueEventTagBuilder) PushState(v interface{}) (r *VueEventTagBuilder)

func (*VueEventTagBuilder) PushStateURL

func (b *VueEventTagBuilder) PushStateURL(v string) (r *VueEventTagBuilder)

func (*VueEventTagBuilder) Queries

func (b *VueEventTagBuilder) Queries(v url.Values) (r *VueEventTagBuilder)

func (*VueEventTagBuilder) Query

func (b *VueEventTagBuilder) Query(key interface{}, vs interface{}) (r *VueEventTagBuilder)

func (*VueEventTagBuilder) QueryIf

func (b *VueEventTagBuilder) QueryIf(key interface{}, vs interface{}, add bool) (r *VueEventTagBuilder)

func (*VueEventTagBuilder) Raw

func (b *VueEventTagBuilder) Raw(script string) (r *VueEventTagBuilder)

func (*VueEventTagBuilder) Reload

func (b *VueEventTagBuilder) Reload() (r *VueEventTagBuilder)

func (*VueEventTagBuilder) RunPushState

func (b *VueEventTagBuilder) RunPushState() (r string)

func (*VueEventTagBuilder) String

func (b *VueEventTagBuilder) String() string

func (*VueEventTagBuilder) StringQuery

func (b *VueEventTagBuilder) StringQuery(v interface{}) (r *VueEventTagBuilder)

func (*VueEventTagBuilder) ThenScript

func (b *VueEventTagBuilder) ThenScript(script string) (r *VueEventTagBuilder)

func (*VueEventTagBuilder) URL

func (b *VueEventTagBuilder) URL(url interface{}) (r *VueEventTagBuilder)

URL is request page url without push state

func (*VueEventTagBuilder) Vars

func (b *VueEventTagBuilder) Vars(v interface{}) (r *VueEventTagBuilder)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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