Documentation
¶
Overview ¶
Package doors builds server-rendered web apps with typed routing, reactive values, and server-handled browser interactions.
Most apps start with NewApp, route the current Location with Route, and render dynamic fragments with Door, Source, and Beam. Event attrs such as AClick, ASubmit, and ALink connect DOM events, forms, and navigation to Go handlers while still producing regular HTML.
For a guided introduction, see the documents embedded in DocsFS.
Index ¶
- Constants
- Variables
- func Call(ctx context.Context, action Action)
- func Free(ctx context.Context) context.Context
- func FreeRoot(ctx context.Context) context.Context
- func Go(f func(context.Context)) gox.Editor
- func IDBytes(b []byte) string
- func IDRand() string
- func IDString(string string) string
- func InstanceEnd(ctx context.Context)
- func InstanceId(ctx context.Context) string
- func Join[T Joiner[T]](values ...T) T
- func Parallel() gox.Proxy
- func ProxyMod(mod gox.Modify) gox.Proxy
- func Reload(ctx context.Context)
- func Route(routes ...RouteSource[Location]) gox.EditorComp
- func RouterBeam(routes ...RouteBeam[Location]) gox.EditorCompdeprecated
- func RouterSource(routes ...RouteSource[Location]) gox.EditorCompdeprecated
- func SessionEnd(ctx context.Context)
- func SessionExpire(ctx context.Context, d time.Duration)
- func SessionId(ctx context.Context) string
- func Status(statusCode int) gox.Editor
- func XCall[T any](ctx context.Context, action Action) <-chan CallResult[T]
- func XReload(ctx context.Context) <-chan error
- type ABlur
- type AChange
- type AClick
- type AData
- type AFocus
- type AFocusIn
- type AFocusOut
- type AGotPointerCapture
- type AHook
- type AInput
- type AKeyDown
- type AKeyUp
- type ALink
- type ALostPointerCapture
- type APointerCancel
- type APointerDown
- type APointerEnter
- type APointerLeave
- type APointerMove
- type APointerOut
- type APointerOver
- type APointerUp
- type ARawHook
- type ARawSubmit
- type AShared
- type ASubmit
- type Action
- type ActionEmit
- type ActionIndicate
- type ActionLocationAssign
- type ActionLocationRawAssign
- type ActionLocationReload
- type ActionLocationReplace
- type ActionScroll
- type Actions
- type Active
- type App
- type Attr
- type Beam
- type CSP
- type CallResult
- type ChangeEvent
- type Classes
- func (c Classes) Add(classes ...string) Classes
- func (c Classes) Clone() Classes
- func (c Classes) Filter(classes ...string) Classes
- func (c Classes) Join(classes ...Classes) Classes
- func (c Classes) Modify(ctx context.Context, tag string, atts gox.Attrs) error
- func (c Classes) Mutate(name string, prev any) any
- func (c Classes) Output(w io.Writer) error
- func (c Classes) Proxy(cur gox.Cursor, el gox.Elem) error
- func (c Classes) Remove(classes ...string) Classes
- func (c Classes) String() string
- type Conf
- type DeriveRoute
- type Door
- type ESProfile
- type ErrorPage
- type FocusEvent
- type Indicator
- type IndicatorAttr
- type IndicatorClass
- type IndicatorClassRemove
- type IndicatorContent
- type Indicators
- type InputEvent
- type JSX
- type Joiner
- type KeyboardEvent
- type Location
- type LocationEncoder
- type MatchRoute
- type ParsedForm
- type PathMatcher
- type PointerEvent
- type QueryMatcher
- type Request
- type RequestAfter
- type RequestChange
- type RequestCommon
- type RequestEvent
- type RequestFocus
- type RequestForm
- type RequestHook
- type RequestInput
- type RequestKeyboard
- type RequestPointer
- type RequestRawForm
- type RequestRawHook
- type Resource
- type ResourceExternal
- type ResourceStatic
- type RouteBeam
- func RouteDefaultBeam[T any, C gox.Comp](render func(Beam[T]) C) RouteBeam[T]
- func RouteDefaultComp[T any](comp gox.Comp) RouteBeam[T]
- func RouteLocationDefaultBeam[C gox.Comp](render func(Beam[Location]) C) RouteBeam[Location]
- func RouteLocationDefaultComp(comp gox.Comp) RouteBeam[Location]
- func RouteModelBeam[M any, C gox.Comp](render func(Beam[M]) C) RouteBeam[Location]
- type RouteSource
- func RouteDefault[T any, C gox.Comp](render func(Source[T]) C) RouteSource[T]
- func RouteLocationDefault[C gox.Comp](render func(Source[Location]) C) RouteSource[Location]
- func RouteModel[M any, C gox.Comp](render func(Source[M]) C) RouteSource[Location]
- func RouteModelSource[M any, C gox.Comp](render func(Source[M]) C) RouteSource[Location]deprecated
- type Scope
- type ScopeBlocking
- type ScopeConcurrent
- type ScopeDebounce
- type ScopeFrame
- type ScopeLatest
- type ScopeSerial
- type Scopes
- type Selector
- type SessionTracker
- type Source
- func DeriveSource[T1 any, T2 comparable](source Source[T1], get func(T1) T2, set func(T1, T2) T1) Source[T2]
- func DeriveSourceEqual[T1 any, T2 any](source Source[T1], get func(T1) T2, set func(T1, T2) T1, ...) Source[T2]
- func NewSource[T comparable](init T) Source[T]
- func NewSourceEqual[T any](init T, equal func(new T, old T) bool) Source[T]
- func NewSourceEqualNoSkip[T any](init T, equal func(new T, old T) bool) Source[T]
- func NewSourceNoSkip[T comparable](init T) Source[T]
- func Router(ctx context.Context) Source[Location]
- type Store
- type Use
- type Watcher
- type With
Examples ¶
Constants ¶
const ( // CacheControlImmutable is for fingerprinted/hashed static assets // (e.g. app.a3f9b2.js, fonts, versioned images) that never change // at a given URL. Cached for 1 year, no revalidation. CacheControlImmutable = "public, max-age=31536000, immutable" // CacheControlStatic is for non-fingerprinted static files // (e.g. /favicon.ico, /robots.txt). Cached for 1 hour, revalidated after. CacheControlStatic = "public, max-age=3600, must-revalidate" // CacheControlStaticShort is for static files that may change occasionally // and where staleness is tolerable for a few minutes. CacheControlStaticShort = "public, max-age=300, must-revalidate" // CacheControlHTML is for HTML entry points (index.html, SSR pages) // where updates should be picked up quickly. Pair with an ETag. CacheControlHTML = "public, max-age=0, must-revalidate" // CacheControlCDN splits browser TTL (1h) from shared/CDN TTL (1d). // Useful when you want fast invalidation at the edge. CacheControlCDN = "public, max-age=3600, s-maxage=86400" // CacheControlPrivate is for per-user responses (dashboards, account pages). // Browsers may cache briefly, CDNs/proxies must not. CacheControlPrivate = "private, max-age=0, must-revalidate" // CacheControlNoCache forces revalidation on every request, but allows // storage. Use when content changes often but ETag/Last-Modified can // produce cheap 304s. CacheControlNoCache = "no-cache" // CacheControlNoStore disables caching entirely. Use for sensitive // responses (auth tokens, personal data, payment flows). CacheControlNoStore = "no-store" // CacheControlAPI is a sensible default for JSON API responses that // shouldn't be cached by intermediaries but can be revalidated. CacheControlAPI = "private, no-cache" )
Cache-Control header presets for common use cases.
Variables ¶
var DocsFS embed.FS
DocsFS is the embedded documentation tree.
Functions ¶
func Call ¶
Call dispatches action to the client without waiting for a result.
Canceling ctx requests best-effort cancellation of the call.
func Free ¶
Free returns a free context that is safe to use with extended Doors operations that may wait, such as X-prefixed methods.
The returned context keeps the original Values from ctx together with the current dynamic ownership and lifecycle.
Use it when waiting should stay scoped to the current dynamic owner.
func FreeRoot ¶ added in v0.8.17
FreeRoot returns a free context that is safe to use with extended Doors operations that may wait, such as X-prefixed methods.
The returned context keeps the original Values from ctx, switches framework features and lifetime to the root Doors context.
Use it for long-running goroutines and work that should outlive the current dynamic owner.
func Go ¶
Go starts f when the surrounding component is rendered.
The passed context is canceled when the dynamic owner is unmounted, which makes Go a good fit for background loops that should stop with the page. The context is also equivalent to calling Free on the surrounding context, so it is safe to use with X* operations that should keep the current dynamic ownership.
Example:
@doors.Go(func(ctx context.Context) {
for {
select {
case <-time.After(time.Second):
door.Update(ctx, currentTime())
case <-ctx.Done():
return
}
}
})
func InstanceEnd ¶
InstanceEnd ends the current instance (tab/window) but keeps the session and other instances active.
func InstanceId ¶
InstanceId returns the unique ID of the current instance. Useful for logging, debugging, and tracking connections.
func Join ¶ added in v0.12.1
func Join[T Joiner[T]](values ...T) T
Join combines values that support [Joiner.And].
It returns the zero value when called without arguments.
func Parallel ¶ added in v0.9.3
Parallel renders the following element on the instance goroutine pool.
Use it for fragments with database queries or external API calls to improve render time.
func ProxyMod ¶ added in v0.9.7
ProxyMod returns a proxy that applies mod to the first real element in the proxied subtree.
Use it to build helpers that attach attributes or attribute modifiers to another element or component. If the subtree starts with a component or container, ProxyMod carries mod forward until it reaches the first element. Text or other non-element output before that element is an error. The modifier is applied once; later sibling elements are left unchanged.
Parallel markers are preserved, so the wrapped subtree can still be scheduled by the Doors renderer.
ProxyMod cannot alter doors.Door content; attempting that returns an error.
func Reload ¶ added in v0.9.0
Reload rerenders the closest dynamic parent.
If ctx belongs to the root page render, nothing is reloaded.
func Route ¶
func Route(routes ...RouteSource[Location]) gox.EditorComp
Route returns a renderable component that routes the current URL through writable route branches.
func RouterBeam
deprecated
added in
v0.12.1
func RouterBeam(routes ...RouteBeam[Location]) gox.EditorComp
Deprecated: Use Route(...)
func RouterSource
deprecated
added in
v0.12.1
func RouterSource(routes ...RouteSource[Location]) gox.EditorComp
Deprecated: Use Route(...)
func SessionEnd ¶
SessionEnd immediately ends the current session and all instances. Use it during logout to close authorized pages and free server resources.
func SessionExpire ¶
SessionExpire sets the maximum lifetime of the current session.
func SessionId ¶
SessionId returns the unique ID of the current session. All instances in the same browser share this ID via a session cookie.
func Status ¶
Status sets the initial HTTP status code for the current page render.
Example:
~(doors.Status(http.StatusNotFound))
func XCall ¶
func XCall[T any](ctx context.Context, action Action) <-chan CallResult[T]
XCall dispatches action to the client and returns a result channel.
The channel receives a CallResult when the client returns a result, then closes. Canceling ctx requests best-effort cancellation; if the call is canceled, the channel closes without a value.
Do not wait on it during rendering. If you need to wait, use Go or your own goroutine with Free. T is the expected decoded payload type. For actions other than ActionEmit, json.RawMessage is usually the right choice.
func XReload ¶ added in v0.9.0
XReload tracks completion of Reload.
The channel receives nil on success or an error on failure, then closes. If ctx belongs to the root page render, it sends an error and closes.
Do not wait on it during rendering. If you need to wait, use Go or your own goroutine with Free.
Types ¶
type ABlur ¶
type ABlur struct {
// Defines how the hook is scheduled (e.g. blocking, debounce).
// Optional.
Scope Scopes
// Visual indicators while the hook is running.
// Optional.
Indicator Indicators
// Actions to run before the hook request.
// Optional.
Before Actions
// Backend event handler.
// Receives a typed RequestEvent[FocusEvent].
// Should return true when the hook is complete and can be removed.
// Required.
On func(context.Context, RequestFocus) bool
// Actions to run on error.
// Optional.
OnError Actions
}
ABlur prepares a blur event hook for DOM elements, with configurable propagation, scheduling, indicators, and handlers.
type AChange ¶
type AChange struct {
// Defines how the hook is scheduled (e.g. blocking, debounce).
// Optional.
Scope Scopes
// Visual indicators while the hook is running.
// Optional.
Indicator Indicators
// Actions to run before the hook request.
// Optional.
Before Actions
// Backend event handler.
// Receives a typed RequestEvent[ChangeEvent].
// Should return true when the hook is complete and can be removed.
// Required.
On func(context.Context, RequestChange) bool
// Actions to run on error.
// Optional.
OnError Actions
}
AChange handles the browser `change` event.
Use it for committed values such as blur-triggered input changes or select changes.
type AClick ¶
type AClick struct {
// If true, stops the event from bubbling up the DOM.
// Optional.
StopPropagation bool
// If true, prevents the browser's default action for the event.
// Optional.
PreventDefault bool
// If true, only fires when the event occurs on this element itself.
// Optional.
ExactTarget bool
// Defines how the hook is scheduled (e.g. blocking, debounce).
// Optional.
Scope Scopes
// Visual indicators while the hook is running.
// Optional.
Indicator Indicators
// Actions to run before the hook request.
// Optional.
Before Actions
// Backend event handler.
// Receives a typed RequestEvent[PointerEvent].
// Should return true when the hook is complete and can be removed.
// Required.
On func(context.Context, RequestPointer) bool
// Actions to run on error.
// Optional.
OnError Actions
}
AClick prepares a click event hook for DOM elements, configuring propagation, scheduling, indicators, and handlers.
type AData ¶
type AData struct {
// Name of the data entry to read via JavaScript with $data(name).
// Required.
Name string
// Value to expose to the client. Marshaled to JSON.
// Required.
Value any
}
AData exposes Value to browser code through `$data(name)`.
`$data(...)` returns strings and JSON-backed values directly. For `[]byte`, it returns a promise that resolves to an `ArrayBuffer`.
type AFocus ¶
type AFocus struct {
// Defines how the hook is scheduled (e.g. blocking, debounce).
// Optional.
Scope Scopes
// Visual indicators while the hook is running.
// Optional.
Indicator Indicators
// Actions to run before the hook request.
// Optional.
Before Actions
// Backend event handler.
// Receives a typed RequestEvent[FocusEvent].
// Should return true when the hook is complete and can be removed.
// Required.
On func(context.Context, RequestFocus) bool
// Actions to run on error.
// Optional.
OnError Actions
}
AFocus prepares a focus event hook for DOM elements, with configurable propagation, scheduling, indicators, and handlers.
type AFocusIn ¶
type AFocusIn struct {
// If true, stops the event from bubbling up the DOM.
// Optional.
StopPropagation bool
// If true, only fires when the event occurs on this element itself.
// Optional.
ExactTarget bool
// Defines how the hook is scheduled (e.g. blocking, debounce).
// Optional.
Scope Scopes
// Visual indicators while the hook is running.
// Optional.
Indicator Indicators
// Actions to run before the hook request.
// Optional.
Before Actions
// Backend event handler.
// Receives a typed RequestEvent[FocusEvent].
// Should return true when the hook is complete and can be removed.
// Required.
On func(context.Context, RequestFocus) bool
// Actions to run on error.
// Optional.
OnError Actions
}
AFocusIn prepares a focusin event hook for DOM elements, with configurable propagation, scheduling, indicators, and handlers.
type AFocusOut ¶
type AFocusOut struct {
// If true, stops the event from bubbling up the DOM.
// Optional.
StopPropagation bool
// If true, only fires when the event occurs on this element itself.
// Optional.
ExactTarget bool
// Defines how the hook is scheduled (e.g. blocking, debounce).
// Optional.
Scope Scopes
// Visual indicators while the hook is running.
// Optional.
Indicator Indicators
// Actions to run before the hook request.
// Optional.
Before Actions
// Backend event handler.
// Receives a typed RequestEvent[FocusEvent].
// Should return true when the hook is complete and can be removed.
// Required.
On func(context.Context, RequestFocus) bool
// Actions to run on error.
// Optional.
OnError Actions
}
AFocusOut prepares a focusout event hook for DOM elements, with configurable propagation, scheduling, indicators, and handlers.
type AGotPointerCapture ¶
type AGotPointerCapture struct {
// If true, stops the event from bubbling up the DOM.
// Optional.
StopPropagation bool
// If true, prevents the browser's default action for the event.
// Optional.
PreventDefault bool
// If true, only fires when the event occurs on this element itself.
// Optional.
ExactTarget bool
// Defines how the hook is scheduled (e.g. blocking, debounce).
// Optional.
Scope Scopes
// Visual indicators while the hook is running.
// Optional.
Indicator Indicators
// Actions to run before the hook request.
// Optional.
Before Actions
// Backend event handler.
// Receives a typed RequestEvent[PointerEvent].
// Should return true when the hook is complete and can be removed.
// Required.
On func(context.Context, RequestPointer) bool
// Actions to run on error.
// Optional.
OnError Actions
}
AGotPointerCapture prepares a gotpointercapture event hook for DOM elements, with configurable propagation, scheduling, indicators, and handlers.
type AHook ¶
type AHook[T any] struct { // Name of the hook to call from JavaScript via $hook(name, ...). // Required. Name string // Defines how the hook is scheduled (e.g. blocking, debounce). // Optional. Scope Scopes // Visual indicators while the hook is running. // Optional. Indicator Indicators // Backend handler for the hook. // Receives typed input (T, unmarshaled from JSON) through RequestHook, // and returns any output which will be marshaled to JSON. // Should return true when the hook is complete and can be removed. // Required. On func(ctx context.Context, r RequestHook[T]) (any, bool) }
AHook exposes a named Go handler to the browser through `$hook(name, ...)`.
Input data is unmarshaled from JSON into type T. The returned value is encoded back to JSON.
type AInput ¶
type AInput struct {
// Defines how the hook is scheduled (e.g. blocking, debounce).
// Optional.
Scope Scopes
// Visual indicators while the hook is running.
// Optional.
Indicator Indicators
// Actions to run before the hook request.
// Optional.
Before Actions
// Backend event handler.
// Receives a typed RequestEvent[InputEvent].
// Should return true when the hook is complete and can be removed.
// Required.
On func(context.Context, RequestInput) bool
// If true, does not include value in event
// Optional.
ExcludeValue bool
// Actions to run on error.
// Optional.
OnError Actions
}
AInput handles the browser `input` event.
Use it for live updates while the user is still editing a value.
type AKeyDown ¶
type AKeyDown struct {
// If true, stops the event from bubbling up the DOM.
// Optional.
StopPropagation bool
// If true, prevents the browser's default action for the event.
// Optional.
PreventDefault bool
// If true, only fires when the event occurs on this element itself.
// Optional.
ExactTarget bool
// Filters by event.key if provided.
// Optional.
Filter []string
// Defines how the hook is scheduled (e.g. blocking, debounce).
// Optional.
Scope Scopes
// Visual indicators while the hook is running.
// Optional.
Indicator Indicators
// Backend event handler.
// Receives a typed RequestEvent[KeyboardEvent].
// Should return true when the hook is complete and can be removed.
// Required.
On func(context.Context, RequestKeyboard) bool
// Actions to run on error.
// Optional.
OnError Actions
// Actions to run before the hook request.
// Optional.
Before Actions
}
AKeyDown prepares a key down event hook for DOM elements, with configurable propagation, scheduling, indicators, and handlers.
type AKeyUp ¶
type AKeyUp struct {
// If true, stops the event from bubbling up the DOM.
// Optional.
StopPropagation bool
// If true, prevents the browser's default action for the event.
// Optional.
PreventDefault bool
// If true, only fires when the event occurs on this element itself.
// Optional.
ExactTarget bool
// Filters by event.key if provided.
// Optional.
Filter []string
// Defines how the hook is scheduled (e.g. blocking, debounce).
// Optional.
Scope Scopes
// Visual indicators while the hook is running.
// Optional.
Indicator Indicators
// Backend event handler.
// Receives a typed RequestEvent[KeyboardEvent].
// Should return true when the hook is complete and can be removed.
// Required.
On func(context.Context, RequestKeyboard) bool
// Actions to run on error.
// Optional.
OnError Actions
// Actions to run before the hook request.
// Optional.
Before Actions
}
AKeyUp prepares a key up event hook for DOM elements, with configurable propagation, scheduling, indicators, and handlers.
type ALink ¶
type ALink struct {
// Target path model value. Required.
Model any
// Fragment identifier. Optional.
Fragment string
// Active link indicator configuration. Optional.
Active Active
// Stop event propagation (for dynamic links). Optional.
StopPropagation bool
// Defines how the hook is scheduled (e.g. blocking, debounce).
// Optional.
Scope Scopes
// Visual indicators while the hook is running. Optional.
Indicator Indicators
// Actions to run before the hook request. Optional.
Before Actions
// Actions to run after the hook request. Optional.
After Actions
// Actions to run on error.
// Default (nil) triggers a location reload.
OnError Actions
}
ALink builds a real href from Model and adds Doors navigation behavior.
A normal click updates the current instance location source and reroutes the page dynamically. The href remains valid for browser features such as opening in a new tab, copying the link, or navigation without client-side runtime.
Example:
attrs := doors.A(ctx, doors.ALink{
Model: Path{Home: true},
})
type ALostPointerCapture ¶
type ALostPointerCapture struct {
// If true, stops the event from bubbling up the DOM.
// Optional.
StopPropagation bool
// If true, prevents the browser's default action for the event.
// Optional.
PreventDefault bool
// If true, only fires when the event occurs on this element itself.
// Optional.
ExactTarget bool
// Defines how the hook is scheduled (e.g. blocking, debounce).
// Optional.
Scope Scopes
// Visual indicators while the hook is running.
// Optional.
Indicator Indicators
// Actions to run before the hook request.
// Optional.
Before Actions
// Backend event handler.
// Receives a typed RequestEvent[PointerEvent].
// Should return true when the hook is complete and can be removed.
// Required.
On func(context.Context, RequestPointer) bool
// Actions to run on error.
// Optional.
OnError Actions
}
ALostPointerCapture prepares a lostpointercapture event hook for DOM elements, with configurable propagation, scheduling, indicators, and handlers.
type APointerCancel ¶
type APointerCancel struct {
// If true, stops the event from bubbling up the DOM.
// Optional.
StopPropagation bool
// If true, prevents the browser's default action for the event.
// Optional.
PreventDefault bool
// If true, only fires when the event occurs on this element itself.
// Optional.
ExactTarget bool
// Defines how the hook is scheduled (e.g. blocking, debounce).
// Optional.
Scope Scopes
// Visual indicators while the hook is running.
// Optional.
Indicator Indicators
// Actions to run before the hook request.
// Optional.
Before Actions
// Backend event handler.
// Receives a typed RequestEvent[PointerEvent].
// Should return true when the hook is complete and can be removed.
// Required.
On func(context.Context, RequestPointer) bool
// Actions to run on error.
// Optional.
OnError Actions
}
APointerCancel prepares a pointer cancel event hook for DOM elements, with configurable propagation, scheduling, indicators, and handlers.
type APointerDown ¶
type APointerDown struct {
// If true, stops the event from bubbling up the DOM.
// Optional.
StopPropagation bool
// If true, prevents the browser's default action for the event.
// Optional.
PreventDefault bool
// If true, only fires when the event occurs on this element itself.
// Optional.
ExactTarget bool
// Defines how the hook is scheduled (e.g. blocking, debounce).
// Optional.
Scope Scopes
// Visual indicators while the hook is running.
// Optional.
Indicator Indicators
// Actions to run before the hook request.
// Optional.
Before Actions
// Backend event handler.
// Receives a typed RequestEvent[PointerEvent].
// Should return true when the hook is complete and can be removed.
// Required.
On func(context.Context, RequestPointer) bool
// Actions to run on error.
// Optional.
OnError Actions
}
APointerDown prepares a pointer down event hook for DOM elements, configuring propagation, scheduling, indicators, and handlers.
type APointerEnter ¶
type APointerEnter struct {
// If true, stops the event from bubbling up the DOM.
// Optional.
StopPropagation bool
// If true, prevents the browser's default action for the event.
// Optional.
PreventDefault bool
// If true, only fires when the event occurs on this element itself.
// Optional.
ExactTarget bool
// Defines how the hook is scheduled (e.g. blocking, debounce).
// Optional.
Scope Scopes
// Visual indicators while the hook is running.
// Optional.
Indicator Indicators
// Actions to run before the hook request.
// Optional.
Before Actions
// Backend event handler.
// Receives a typed RequestEvent[PointerEvent].
// Should return true when the hook is complete and can be removed.
// Required.
On func(context.Context, RequestPointer) bool
// Actions to run on error.
// Optional.
OnError Actions
}
APointerEnter prepares a pointer enter event hook for DOM elements, with configurable propagation, scheduling, indicators, and handlers.
type APointerLeave ¶
type APointerLeave struct {
// If true, stops the event from bubbling up the DOM.
// Optional.
StopPropagation bool
// If true, prevents the browser's default action for the event.
// Optional.
PreventDefault bool
// If true, only fires when the event occurs on this element itself.
// Optional.
ExactTarget bool
// Defines how the hook is scheduled (e.g. blocking, debounce).
// Optional.
Scope Scopes
// Visual indicators while the hook is running.
// Optional.
Indicator Indicators
// Actions to run before the hook request.
// Optional.
Before Actions
// Backend event handler.
// Receives a typed RequestEvent[PointerEvent].
// Should return true when the hook is complete and can be removed.
// Required.
On func(context.Context, RequestPointer) bool
// Actions to run on error.
// Optional.
OnError Actions
}
APointerLeave prepares a pointer leave event hook for DOM elements, with configurable propagation, scheduling, indicators, and handlers.
type APointerMove ¶
type APointerMove struct {
// If true, stops the event from bubbling up the DOM.
// Optional.
StopPropagation bool
// If true, prevents the browser's default action for the event.
// Optional.
PreventDefault bool
// If true, only fires when the event occurs on this element itself.
// Optional.
ExactTarget bool
// Defines how the hook is scheduled (e.g. blocking, debounce).
// Optional.
Scope Scopes
// Visual indicators while the hook is running.
// Optional.
Indicator Indicators
// Actions to run before the hook request.
// Optional.
Before Actions
// Backend event handler.
// Receives a typed RequestEvent[PointerEvent].
// Should return true when the hook is complete and can be removed.
// Required.
On func(context.Context, RequestPointer) bool
// Actions to run on error.
// Optional.
OnError Actions
}
APointerMove prepares a pointer move event hook for DOM elements, configuring propagation, scheduling, indicators, and handlers.
type APointerOut ¶
type APointerOut struct {
// If true, stops the event from bubbling up the DOM.
// Optional.
StopPropagation bool
// If true, prevents the browser's default action for the event.
// Optional.
PreventDefault bool
// If true, only fires when the event occurs on this element itself.
// Optional.
ExactTarget bool
// Defines how the hook is scheduled (e.g. blocking, debounce).
// Optional.
Scope Scopes
// Visual indicators while the hook is running.
// Optional.
Indicator Indicators
// Actions to run before the hook request.
// Optional.
Before Actions
// Backend event handler.
// Receives a typed RequestEvent[PointerEvent].
// Should return true when the hook is complete and can be removed.
// Required.
On func(context.Context, RequestPointer) bool
// Actions to run on error.
// Optional.
OnError Actions
}
APointerOut prepares a pointer out event hook for DOM elements, with configurable propagation, scheduling, indicators, and handlers.
type APointerOver ¶
type APointerOver struct {
// If true, stops the event from bubbling up the DOM.
// Optional.
StopPropagation bool
// If true, prevents the browser's default action for the event.
// Optional.
PreventDefault bool
// If true, only fires when the event occurs on this element itself.
// Optional.
ExactTarget bool
// Defines how the hook is scheduled (e.g. blocking, debounce).
// Optional.
Scope Scopes
// Visual indicators while the hook is running.
// Optional.
Indicator Indicators
// Actions to run before the hook request.
// Optional.
Before Actions
// Backend event handler.
// Receives a typed RequestEvent[PointerEvent].
// Should return true when the hook is complete and can be removed.
// Required.
On func(context.Context, RequestPointer) bool
// Actions to run on error.
// Optional.
OnError Actions
}
APointerOver prepares a pointer over event hook for DOM elements, configuring propagation, scheduling, indicators, and handlers.
type APointerUp ¶
type APointerUp struct {
// If true, stops the event from bubbling up the DOM.
// Optional.
StopPropagation bool
// If true, prevents the browser's default action for the event.
// Optional.
PreventDefault bool
// If true, only fires when the event occurs on this element itself.
// Optional.
ExactTarget bool
// Defines how the hook is scheduled (e.g. blocking, debounce).
// Optional.
Scope Scopes
// Visual indicators while the hook is running.
// Optional.
Indicator Indicators
// Actions to run before the hook request.
// Optional.
Before Actions
// Backend event handler.
// Receives a typed RequestEvent[PointerEvent].
// Should return true when the hook is complete and can be removed.
// Required.
On func(context.Context, RequestPointer) bool
// Actions to run on error.
// Optional.
OnError Actions
}
APointerUp prepares a pointer up event hook for DOM elements, configuring propagation, scheduling, indicators, and handlers.
type ARawHook ¶
type ARawHook struct {
// Name of the hook to call from JavaScript via $hook(name, ...).
// Required.
Name string
// Defines how the hook is scheduled (e.g. blocking, debounce).
// Optional.
Scope Scopes
// Visual indicators while the hook is running.
// Optional.
Indicator Indicators
// Backend handler for the hook.
// Provides raw access via RRawHook (body reader, multipart parser).
// Should return true when the hook is complete and can be removed.
// Required.
On func(ctx context.Context, r RequestRawHook) bool
}
ARawHook exposes a named Go handler to the browser through `$hook(name, ...)` without JSON decoding or encoding.
Use it for streaming, custom protocols, or file uploads.
type ARawSubmit ¶
type ARawSubmit struct {
// Defines how the hook is scheduled (e.g. blocking, debounce).
// Optional.
Scope Scopes
// Visual indicators while the hook is running.
// Optional.
Indicator Indicators
// Actions to run before the hook request.
// Optional.
Before Actions
// Backend form handler.
// Should return true when the hook is complete and can be removed.
// Required.
On func(context.Context, RequestRawForm) bool
// Actions to run on error.
// Optional.
OnError Actions
}
ARawSubmit handles a form submission with raw multipart access.
type AShared ¶
type AShared = *aShared
AShared is a reusable dynamic attribute handle shared across every element it is attached to.
func NewAShared ¶
NewAShared returns an enabled shared attribute handle.
Update, Enable, and Disable affect every attached element together.
type ASubmit ¶
type ASubmit[T any] struct { // MaxMemory sets the maximum number of bytes to parse into memory. // It is passed to ParseMultipartForm. // Defaults to 8 MB if zero. MaxMemory int // Defines how the hook is scheduled (e.g. blocking, debounce). // Optional. Scope Scopes // Visual indicators while the hook is running. // Optional. Indicator Indicators // Actions to run before the hook request. // Optional. Before Actions // Backend form handler. // Should return true when the hook is complete and can be removed. // Required. On func(context.Context, RequestForm[T]) bool // Actions to run on error. // Optional. OnError Actions }
ASubmit handles a form submission by decoding it into T with go-playground/form.
type Action ¶
type Action interface {
// contains filtered or unexported methods
}
Action performs a client-side operation.
type ActionEmit ¶
ActionEmit invokes a client-side handler registered with `$on(name, handler)`.
func (ActionEmit) Actions ¶ added in v0.12.1
func (ae ActionEmit) Actions() []Action
func (ActionEmit) And ¶ added in v0.12.1
func (ae ActionEmit) And(a Actions) Actions
type ActionIndicate ¶
type ActionIndicate struct {
Indicator Indicators
Duration time.Duration
}
ActionIndicate applies indicators for Duration.
func (ActionIndicate) Actions ¶ added in v0.12.1
func (ai ActionIndicate) Actions() []Action
func (ActionIndicate) And ¶ added in v0.12.1
func (ai ActionIndicate) And(a Actions) Actions
type ActionLocationAssign ¶
type ActionLocationAssign struct {
Model any
}
ActionLocationAssign navigates to a model-derived URL.
func (ActionLocationAssign) Actions ¶ added in v0.12.1
func (aa ActionLocationAssign) Actions() []Action
func (ActionLocationAssign) And ¶ added in v0.12.1
func (aa ActionLocationAssign) And(a Actions) Actions
type ActionLocationRawAssign ¶
type ActionLocationRawAssign struct {
URL string
}
ActionLocationRawAssign navigates to url without first encoding a path model.
func (ActionLocationRawAssign) Actions ¶ added in v0.12.1
func (aa ActionLocationRawAssign) Actions() []Action
func (ActionLocationRawAssign) And ¶ added in v0.12.1
func (aa ActionLocationRawAssign) And(a Actions) Actions
type ActionLocationReload ¶
type ActionLocationReload struct{}
ActionLocationReload reloads the current page.
func (ActionLocationReload) Actions ¶ added in v0.12.1
func (ar ActionLocationReload) Actions() []Action
func (ActionLocationReload) And ¶ added in v0.12.1
func (ar ActionLocationReload) And(a Actions) Actions
type ActionLocationReplace ¶
type ActionLocationReplace struct {
Model any
}
ActionLocationReplace replaces the current history entry with a model-derived URL.
func (ActionLocationReplace) Actions ¶ added in v0.12.1
func (ar ActionLocationReplace) Actions() []Action
func (ActionLocationReplace) And ¶ added in v0.12.1
func (ar ActionLocationReplace) And(a Actions) Actions
type ActionScroll ¶
type ActionScroll struct {
// CSS selector for the element to scroll into view.
Selector string
// Browser scroll options forwarded to `scrollIntoView(...)`.
Options any
}
ActionScroll scrolls the first element matching Selector into view.
Options is passed to the browser scroll call as-is and should match the shape accepted by `Element.scrollIntoView(...)`, for example: `map[string]any{"behavior": "smooth", "block": "center"}`.
func (ActionScroll) Actions ¶ added in v0.12.1
func (aa ActionScroll) Actions() []Action
func (ActionScroll) And ¶ added in v0.12.1
func (aa ActionScroll) And(a Actions) Actions
type Actions ¶ added in v0.12.1
type Actions interface {
// Actions returns the flattened action list.
Actions() []Action
Joiner[Actions]
}
Actions is a composable list of client-side operations.
func JoinActions ¶ added in v0.12.1
JoinActions combines several client actions into one value.
type Active ¶
type Active struct {
// PathMatcher controls path matching. Defaults to [PathMatcherFull].
PathMatcher PathMatcher
// QueryMatcher controls query matching. Matchers are applied sequentially;
// any remaining parameters are compared after the configured matcher chain.
QueryMatcher QueryMatcher
// FragmentMatch includes the URL fragment in active matching.
FragmentMatch bool
// Indicator is applied to the link while it matches the current location.
Indicator Indicators
}
Active configures how ALink marks itself as active.
type App ¶ added in v0.12.1
type App interface {
// Use appends middleware around the app handler.
Use(middleware ...Use)
// InstanceCount returns the number of live instances across all sessions.
InstanceCount() int
// SessionCount returns the number of active sessions.
SessionCount() int
http.Handler
}
App is a Doors application and HTTP handler.
type Attr ¶
Attr is a Doors attribute modifier that can be attached directly to an element or applied through a proxy component.
type Beam ¶
type Beam[T any] interface { // Effect returns the current value and rerenders the closest dynamic parent // when the value changes. Effect(ctx context.Context) (T, bool) // Bind renders f with the current value and rerenders that fragment when // the value changes. Bind(func(T) gox.Elem) gox.EditorComp // RouteBeam returns a renderable component that renders the first matching // read-only route for this beam. RouteBeam(routes ...RouteBeam[T]) gox.EditorComp // Sub subscribes to the value stream. onValue is called immediately with the // current value in the same goroutine, and again on every update. // // The subscription continues until: // - onValue returns true, or // - a dynamic parent is unmounted. // // It returns false if the context was already canceled or does not belong to // an instance runtime. Sub(ctx context.Context, onValue func(context.Context, T) bool) bool // Read returns the current value without creating a subscription. // // It returns false if the context was canceled or does not belong to an // instance runtime. Read(ctx context.Context) (T, bool) // ReadAndSub returns the current value and then subscribes to future // updates. onValue is called only for subsequent updates. // // It returns false if the context was canceled or does not belong to an // instance runtime. ReadAndSub(ctx context.Context, onValue func(context.Context, T) bool) (T, bool) // Watch attaches a low-level watcher for separate init, update, and // cancellation callbacks. Watch(ctx context.Context, w Watcher[T]) (context.CancelFunc, bool) // Get returns the most recently stored value without requiring a runtime // context. // // Unlike [Beam.Read], Get does not participate in render-cycle consistency // guarantees. Use Read when consistency across the component tree matters. Get() T // contains filtered or unexported methods }
Beam is a read-only reactive value.
Use a Beam to read, subscribe to, or derive a smaller view of a value. During one render/update cycle, a Door subtree observes one consistent value for the same beam.
func DeriveBeam ¶ added in v0.12.1
func DeriveBeam[T1 any, T2 comparable](source Beam[T1], get func(T1) T2) Beam[T2]
DeriveBeam derives a Beam from source and uses `==` to suppress equal derived values.
Example:
fullName := doors.DeriveBeam(user, func(u User) string {
return u.FirstName + " " + u.LastName
})
func DeriveBeamEqual ¶ added in v0.12.1
func DeriveBeamEqual[T1 any, T2 any](source Beam[T1], get func(T1) T2, equal func(new T2, old T2) bool) Beam[T2]
DeriveBeamEqual derives a Beam from source with a custom equality function.
equal should report whether new and old should be treated as equal and therefore not propagated. If equal is nil, every derived value propagates.
type CallResult ¶
CallResult holds the outcome of XCall. Either Ok is set with the result, or Err is non-nil.
type ChangeEvent ¶
type ChangeEvent = front.ChangeEvent
ChangeEvent is the payload sent to AChange handlers.
type Classes ¶ added in v0.9.7
type Classes struct {
// contains filtered or unexported fields
}
Classes describes class names to add and filter out.
Classes values are immutable: Add, Remove, Filter, Join, and Clone return a new value and leave the receiver unchanged.
func Class ¶ added in v0.9.7
Class returns a Classes value from one or more class strings.
Each argument is split with strings.Fields, so Class("a", "b c") and Class("a b c") produce the same classes. The returned value can be used as a class attribute value, as an attribute modifier, or as a proxy before an element/component.
func (Classes) Add ¶ added in v0.9.7
Add returns a new Classes value with classes appended.
Arguments are split like Class, so Add("a", "b c") adds three classes.
func (Classes) Filter ¶ added in v0.9.7
Filter returns a new Classes value that omits matching classes from output.
Removed classes are filtered regardless of whether they were added before or after Filter was called.
func (Classes) Join ¶ added in v0.9.7
Join returns a new Classes value that combines several class modifiers.
Both added and filtered class names are preserved, so filters from joined values still affect the final rendered class list.
func (Classes) Remove ¶ added in v0.9.7
Remove returns a new Classes value with matching currently-added classes removed.
Removed classes are not remembered: the same class can be added again later. Use Filter when matching classes should be omitted from final output even if they are added later or come from a joined Classes value.
type DeriveRoute ¶ added in v0.12.1
type DeriveRoute[T1, T2 any] struct { // contains filtered or unexported fields }
DeriveRoute builds routes that render a derived value from the routed value.
func RouteDerive ¶ added in v0.12.1
func RouteDerive[T1 any, T2 comparable](derive func(T1) (T2, bool)) DeriveRoute[T1, T2]
RouteDerive starts a route builder that matches when derive returns ok and exposes the derived value to the route render function.
func RouteDeriveEqual ¶ added in v0.12.1
func RouteDeriveEqual[T1 any, T2 any](derive func(T1) (T2, bool), equal func(T2, T2) bool) DeriveRoute[T1, T2]
RouteDeriveEqual is like RouteDerive with custom equality for the derived value. If equal is nil, every matched update propagates.
func (DeriveRoute[T1, T2]) Beam ¶ added in v0.12.1
func (r DeriveRoute[T1, T2]) Beam(render func(Beam[T2]) gox.Elem) RouteBeam[T1]
Beam creates a read-only route for the derived value.
func (DeriveRoute[T1, T2]) Source ¶ added in v0.12.1
func (r DeriveRoute[T1, T2]) Source(set func(T1, T2) T1, render func(Source[T2]) gox.Elem) RouteSource[T1]
Source creates a writable route for the derived value.
type Door ¶
Door is a dynamic placeholder in the DOM tree that can be updated, replaced, or removed after render.
Doors start inactive and become active when rendered. Operations on an inactive door are stored virtually and applied when the door becomes active. If a door is removed or replaced, it becomes inactive again, but operations continue to update that virtual content for future rendering.
The context used while rendering a door's content follows the door's lifecycle, which makes `ctx.Done()` safe to use in background goroutines that depend on the door staying mounted.
X-prefixed methods return a channel that reports completion. For inactive doors, that channel closes immediately without sending a value.
type ESProfile ¶ added in v0.12.1
type ESProfile struct {
// External lists module specifiers that esbuild should leave external.
External []string
// Minify enables esbuild syntax, whitespace, and identifier minification.
Minify bool
// JSX configures JSX transformation.
JSX JSX
}
ESProfile is a simple WithESProfiles option.
type FocusEvent ¶
type FocusEvent = front.FocusEvent
FocusEvent is the payload sent to focus event handlers.
type IndicatorAttr ¶
type IndicatorAttr struct {
Selector Selector // Target element
Name string // Attribute name
Value string // Attribute value
}
IndicatorAttr temporarily sets an attribute on the selected element.
func IndicateAttr ¶ added in v0.12.1
func IndicateAttr(name, value string) IndicatorAttr
IndicateAttr builds an IndicatorAttr that targets the event element.
func IndicateAttrQuery ¶ added in v0.12.1
func IndicateAttrQuery(query, name, value string) IndicatorAttr
IndicateAttrQuery builds an IndicatorAttr that targets the first element matching query.
func IndicateAttrQueryAll ¶ added in v0.12.1
func IndicateAttrQueryAll(query, name, value string) IndicatorAttr
IndicateAttrQueryAll builds an IndicatorAttr that targets every element matching query.
func IndicateAttrQueryParent ¶ added in v0.12.1
func IndicateAttrQueryParent(query, name, value string) IndicatorAttr
IndicateAttrQueryParent builds an IndicatorAttr that targets the closest ancestor matching query.
func (IndicatorAttr) And ¶ added in v0.12.1
func (ia IndicatorAttr) And(i Indicators) Indicators
func (IndicatorAttr) Indicators ¶ added in v0.12.1
func (ia IndicatorAttr) Indicators() []Indicator
type IndicatorClass ¶
type IndicatorClass struct {
Selector Selector // Target element
Class string // Space-separated classes
}
IndicatorClass temporarily adds CSS classes to the selected element.
func IndicateClass ¶ added in v0.12.1
func IndicateClass(class string) IndicatorClass
IndicateClass builds an IndicatorClass that targets the event element.
func IndicateClassQuery ¶ added in v0.12.1
func IndicateClassQuery(query, class string) IndicatorClass
IndicateClassQuery builds an IndicatorClass that targets the first element matching query.
func IndicateClassQueryAll ¶ added in v0.12.1
func IndicateClassQueryAll(query, class string) IndicatorClass
IndicateClassQueryAll builds an IndicatorClass that targets every element matching query.
func IndicateClassQueryParent ¶ added in v0.12.1
func IndicateClassQueryParent(query, class string) IndicatorClass
IndicateClassQueryParent builds an IndicatorClass that targets the closest ancestor matching query.
func (IndicatorClass) And ¶ added in v0.12.1
func (ic IndicatorClass) And(i Indicators) Indicators
func (IndicatorClass) Indicators ¶ added in v0.12.1
func (ic IndicatorClass) Indicators() []Indicator
type IndicatorClassRemove ¶
type IndicatorClassRemove struct {
Selector Selector // Target element
Class string // Space-separated classes
}
IndicatorClassRemove temporarily removes CSS classes from the selected element.
func IndicateClassRemove ¶ added in v0.12.1
func IndicateClassRemove(class string) IndicatorClassRemove
IndicateClassRemove builds an IndicatorClassRemove that targets the event element.
func IndicateClassRemoveQuery ¶ added in v0.12.1
func IndicateClassRemoveQuery(query, class string) IndicatorClassRemove
IndicateClassRemoveQuery builds an IndicatorClassRemove that targets the first element matching query.
func IndicateClassRemoveQueryAll ¶ added in v0.12.1
func IndicateClassRemoveQueryAll(query, class string) IndicatorClassRemove
IndicateClassRemoveQueryAll builds an IndicatorClassRemove that targets every element matching query.
func IndicateClassRemoveQueryParent ¶ added in v0.12.1
func IndicateClassRemoveQueryParent(query, class string) IndicatorClassRemove
IndicateClassRemoveQueryParent builds an IndicatorClassRemove that targets the closest ancestor matching query.
func (IndicatorClassRemove) And ¶ added in v0.12.1
func (irc IndicatorClassRemove) And(i Indicators) Indicators
func (IndicatorClassRemove) Indicators ¶ added in v0.12.1
func (irc IndicatorClassRemove) Indicators() []Indicator
type IndicatorContent ¶
type IndicatorContent struct {
Selector Selector // Target element
Content string // Replacement content
}
func IndicateContent ¶ added in v0.12.1
func IndicateContent(content string) IndicatorContent
IndicateContent builds an IndicatorContent that targets the event element.
func IndicateContentQuery ¶ added in v0.12.1
func IndicateContentQuery(query, content string) IndicatorContent
IndicateContentQuery builds an IndicatorContent that targets the first element matching query.
func IndicateContentQueryAll ¶ added in v0.12.1
func IndicateContentQueryAll(query, content string) IndicatorContent
IndicateContentQueryAll builds an IndicatorContent that targets every element matching query.
func IndicateContentQueryParent ¶ added in v0.12.1
func IndicateContentQueryParent(query, content string) IndicatorContent
IndicateContentQueryParent builds an IndicatorContent that targets the closest ancestor matching query.
func (IndicatorContent) And ¶ added in v0.12.1
func (ic IndicatorContent) And(i Indicators) Indicators
func (IndicatorContent) Indicators ¶ added in v0.12.1
func (ic IndicatorContent) Indicators() []Indicator
type Indicators ¶ added in v0.12.1
type Indicators interface {
Indicators() []Indicator
Joiner[Indicators]
}
Indicators is a temporary DOM change applied on the client.
Indicators are commonly used for pending UI such as "Loading..." text, temporary classes, or transient attributes while a request is in flight.
func JoinIndicators ¶ added in v0.12.1
func JoinIndicators(values ...Indicators) Indicators
JoinIndicators combines several indicators into one value.
type InputEvent ¶
type InputEvent = front.InputEvent
InputEvent is the payload sent to AInput handlers.
type JSX ¶
type JSX struct {
JSX api.JSX
Factory string
ImportSource string
Fragment string
SideEffects bool
Dev bool
}
JSX configures how esbuild should transform JSX input.
type Joiner ¶ added in v0.12.1
type Joiner[T any] interface { // And returns a value that applies the receiver followed by T. And(T) T }
Joiner is implemented by composable option-like values.
type KeyboardEvent ¶
type KeyboardEvent = front.KeyboardEvent
KeyboardEvent is the payload sent to keyboard event handlers.
type Location ¶
Location is a parsed or generated URL path plus query string.
Example ¶
loc := Location{
Segments: []string{"posts", "42"},
Query: url.Values{
"tag": []string{"go"},
"page": []string{"2"},
},
}
fmt.Println(loc.String())
Output: /posts/42?page=2&tag=go
func NewLocation ¶
NewLocation encodes model into a Location.
model may be a Location, a path-model struct, a pointer to a path-model struct, or a value implementing LocationEncoder.
Example ¶
loc, err := NewLocation(examplePath{Post: true, ID: 42})
if err != nil {
panic(err)
}
fmt.Println(loc.String())
Output: /posts/42
type LocationEncoder ¶ added in v0.12.1
LocationEncoder is implemented by custom navigation models that can encode themselves as a Location.
type MatchRoute ¶ added in v0.12.1
type MatchRoute[T any] struct { // contains filtered or unexported fields }
MatchRoute builds routes that render the full routed value when a predicate matches.
func RouteMatch ¶ added in v0.12.1
func RouteMatch[T any](match func(T) bool) MatchRoute[T]
RouteMatch starts a route builder that matches when pred returns true and renders the full routed value.
func RouteValue ¶ added in v0.12.1
func RouteValue[T comparable](v T) MatchRoute[T]
RouteValue starts a route builder that matches values equal to v.
func (MatchRoute[T]) Beam ¶ added in v0.12.1
func (m MatchRoute[T]) Beam(render func(Beam[T]) gox.Elem) RouteBeam[T]
Beam creates a read-only route for the full routed value.
func (MatchRoute[T]) Comp ¶ added in v0.12.1
func (m MatchRoute[T]) Comp(comp gox.Comp) RouteBeam[T]
Comp creates a route that renders comp when this matcher is active.
func (MatchRoute[T]) Source ¶ added in v0.12.1
func (m MatchRoute[T]) Source(render func(Source[T]) gox.Elem) RouteSource[T]
Source creates a writable route for the full routed value.
type ParsedForm ¶
type ParsedForm interface {
// FormValues returns all parsed form values.
FormValues() url.Values
// FormValue returns the first value for the given key.
FormValue(key string) string
// FormFile returns the uploaded file for the given key.
FormFile(key string) (multipart.File, *multipart.FileHeader, error)
// Form returns the underlying multipart.Form.
Form() *multipart.Form
}
ParsedForm exposes parsed multipart form values and files.
type PathMatcher ¶
type PathMatcher interface {
// contains filtered or unexported methods
}
PathMatcher customizes how the path participates in active-link matching.
func PathMatcherFull ¶
func PathMatcherFull() PathMatcher
PathMatcherFull matches the full generated path.
func PathMatcherSegments ¶
func PathMatcherSegments(i ...int) PathMatcher
PathMatcherSegments matches only the listed path segment indexes (zero-based).
func PathMatcherStarts ¶
func PathMatcherStarts() PathMatcher
PathMatcherStarts matches when the current path starts with the link path.
type PointerEvent ¶
type PointerEvent = front.PointerEvent
PointerEvent is the payload sent to pointer event handlers.
type QueryMatcher ¶
type QueryMatcher interface {
Joiner[QueryMatcher]
// contains filtered or unexported methods
}
QueryMatcher customizes how query parameters participate in active-link matching. Matchers can be chained with [QueryMatcher.And].
func QueryMatcherIfPresent ¶
func QueryMatcherIfPresent(params ...string) QueryMatcher
QueryMatcherIfPresent matches the given parameters only if they are present.
func QueryMatcherIgnoreAll ¶
func QueryMatcherIgnoreAll() QueryMatcher
QueryMatcherIgnoreAll excludes all remaining query parameters from comparison.
func QueryMatcherIgnoreSome ¶
func QueryMatcherIgnoreSome(params ...string) QueryMatcher
QueryMatcherIgnoreSome excludes the given query parameters from comparison.
func QueryMatcherSome ¶
func QueryMatcherSome(params ...string) QueryMatcher
QueryMatcherSome compares only the provided query parameters at this step.
type Request ¶
type Request interface {
RequestCommon
// RequestHeader returns the incoming request headers.
RequestHeader() http.Header
// ResponseHeader returns the outgoing response headers.
ResponseHeader() http.Header
}
Request is the request context passed to main app handler.
Use it for cookies, request headers, and response headers.
type RequestAfter ¶
type RequestAfter interface {
// After appends client-side actions to the successful response.
After(a Actions) error
}
RequestAfter schedules client-side actions to run after a successful request.
type RequestChange ¶
type RequestChange = RequestEvent[ChangeEvent]
RequestChange is the typed request passed to AChange handlers.
type RequestCommon ¶ added in v0.12.1
type RequestCommon interface {
// SetCookie adds a cookie to the response.
SetCookie(cookie *http.Cookie)
// GetCookie retrieves a cookie by name.
GetCookie(name string) (*http.Cookie, error)
// Context returns the underlying HTTP request context.
// It is not the Doors runtime context passed to handlers.
Context() context.Context
}
RequestCommon exposes the common server-side request helpers available to Doors handlers.
type RequestEvent ¶
type RequestEvent[E any] interface { RequestCommon RequestAfter // Event returns the event payload. Event() E }
RequestEvent is the request context passed to event handlers.
type RequestFocus ¶
type RequestFocus = RequestEvent[FocusEvent]
RequestFocus is the typed request passed to focus event handlers.
type RequestForm ¶
type RequestForm[D any] interface { RequestCommon RequestAfter // Data returns the parsed form payload. Data() D }
RequestForm is the request context passed to decoded form handlers.
type RequestHook ¶
type RequestHook[D any] interface { RequestCommon RequestAfter // Data returns the parsed hook payload. Data() D }
RequestHook is the request context passed to typed JavaScript hook handlers.
type RequestInput ¶
type RequestInput = RequestEvent[InputEvent]
RequestInput is the typed request passed to AInput handlers.
type RequestKeyboard ¶
type RequestKeyboard = RequestEvent[KeyboardEvent]
RequestKeyboard is the typed request passed to keyboard event handlers.
type RequestPointer ¶
type RequestPointer = RequestEvent[PointerEvent]
RequestPointer is the typed request passed to pointer event handlers.
type RequestRawForm ¶
type RequestRawForm interface {
RequestCommon
RequestAfter
// ResponseWriter returns the HTTP response writer.
ResponseWriter() http.ResponseWriter
// Reader returns a multipart reader for streaming form parts.
Reader() (*multipart.Reader, error)
// ParseForm parses the form data with a memory limit.
ParseForm(maxMemory int) (ParsedForm, error)
}
RequestRawForm is the request context passed to raw multipart form handlers.
type RequestRawHook ¶
type RequestRawHook interface {
RequestRawForm
// Body returns the raw request body reader.
Body() io.ReadCloser
}
RequestRawHook is the request context passed to raw JavaScript hook handlers.
type Resource ¶
type Resource = printer.SourceHandler
Resource describes content or a URL that can be attached to HTML resource attrs such as `src` and `href`.
Managed resources may be hosted by Doors when the tag and attrs require it.
func ResourceHandler ¶
func ResourceHandler(handler func(w http.ResponseWriter, r *http.Request)) Resource
ResourceHandler serves content through a standard library-style handler.
func ResourceHook ¶
func ResourceHook(handler func(ctx context.Context, w http.ResponseWriter, r *http.Request) bool) Resource
ResourceHook serves content through a custom resource handler.
Use it for dynamic or request-dependent content that should be exposed through a managed Doors resource URL.
Returning true tells Doors it may remove the generated private resource after the request.
func ResourceProxy ¶
ResourceProxy serves a resource by reverse-proxying requests to url.
Unlike ResourceExternal, the browser still loads the resource from a Doors-managed URL.
type ResourceExternal ¶
type ResourceExternal = printer.SourceExternal
ResourceExternal is a direct external URL.
Use it when the browser should load the resource from another host without proxying it through Doors, while still letting Doors collect the host for Content-Security-Policy generation.
type ResourceStatic ¶
type ResourceStatic = printer.SourceStatic
ResourceStatic is a Resource whose content is known up front.
Static resources can be shared through cached public URLs and mounted at fixed public routes with UseResource.
func ResourceBytes ¶
func ResourceBytes(content []byte) ResourceStatic
ResourceBytes serves in-memory bytes as a ResourceStatic.
func ResourceFS ¶
func ResourceFS(fsys fs.FS, entry string) ResourceStatic
ResourceFS serves one file from fsys as a ResourceStatic.
func ResourceLocalFS ¶
func ResourceLocalFS(path string) ResourceStatic
ResourceLocalFS serves one local file from path as a ResourceStatic.
func ResourceString ¶
func ResourceString(content string) ResourceStatic
ResourceString serves in-memory string content as a ResourceStatic.
type RouteBeam ¶ added in v0.12.1
type RouteBeam[T1 any] interface { RouteSource[T1] // contains filtered or unexported methods }
RouteBeam is a read-only route branch for values of type T1.
func RouteDefaultBeam ¶ added in v0.12.1
RouteDefaultBeam creates a fallback route that always matches and renders a read-only beam for the full routed value.
func RouteDefaultComp ¶ added in v0.12.1
RouteDefaultComp creates a fallback route that always matches and renders comp.
func RouteLocationDefaultBeam ¶ added in v0.12.1
RouteLocationDefaultBeam creates a fallback URL route that renders a read-only beam for the current Location.
func RouteLocationDefaultComp ¶ added in v0.12.1
RouteLocationDefaultComp creates a fallback URL route that renders comp.
type RouteSource ¶ added in v0.12.1
type RouteSource[T1 any] interface { // contains filtered or unexported methods }
RouteSource is a writable route branch for values of type T1.
func RouteDefault ¶ added in v0.12.4
func RouteDefault[T any, C gox.Comp](render func(Source[T]) C) RouteSource[T]
RouteDefault creates a fallback route that always matches and renders a writable source for the full routed value.
func RouteLocationDefault ¶ added in v0.12.4
RouteLocationDefault creates a fallback URL route that renders a writable source for the current Location.
func RouteModel ¶ added in v0.12.3
RouteModel creates a URL route for path model M and renders a writable source for the decoded model.
The route matches when the current Location decodes into M. Updating the source re-encodes M back into the current location.
func RouteModelSource
deprecated
added in
v0.12.1
type ScopeBlocking ¶
type ScopeBlocking struct {
// contains filtered or unexported fields
}
ScopeBlocking allows only one request in this scope to run at a time.
Later requests are rejected while an earlier request is active.
func (*ScopeBlocking) And ¶ added in v0.12.1
func (sb *ScopeBlocking) And(s Scopes) Scopes
type ScopeConcurrent ¶
type ScopeConcurrent struct {
// contains filtered or unexported fields
}
ScopeConcurrent allows one request per group to run concurrently.
func (*ScopeConcurrent) Scope ¶
func (d *ScopeConcurrent) Scope(groupID int) Scopes
Scope returns a concurrent scheduling group.
type ScopeDebounce ¶
type ScopeDebounce struct {
// Duration is the quiet period before a request is sent.
Duration time.Duration
// Limit is the maximum delay before a pending request must be sent.
Limit time.Duration
// contains filtered or unexported fields
}
ScopeDebounce delays requests until input settles.
func (*ScopeDebounce) And ¶ added in v0.12.1
func (sd *ScopeDebounce) And(s Scopes) Scopes
type ScopeFrame ¶
type ScopeFrame struct {
// contains filtered or unexported fields
}
ScopeFrame groups requests by frame lifecycle.
func (*ScopeFrame) Scope ¶
func (d *ScopeFrame) Scope(frame bool) Scopes
Scope returns a scope for either the frame or non-frame group.
type ScopeLatest ¶
type ScopeLatest struct {
// contains filtered or unexported fields
}
ScopeLatest keeps only the latest request in this scope.
func (*ScopeLatest) And ¶ added in v0.12.1
func (sl *ScopeLatest) And(s Scopes) Scopes
type ScopeSerial ¶
type ScopeSerial struct {
// contains filtered or unexported fields
}
ScopeSerial queues requests in this scope and runs them one after another.
func (*ScopeSerial) And ¶ added in v0.12.1
func (ss *ScopeSerial) And(s Scopes) Scopes
type Scopes ¶ added in v0.12.1
type Scopes interface {
// Scopes returns the low-level client scopes for this app core.
Scopes(core core.Core) []Scope
Joiner[Scopes]
}
Scopes configures how hook requests are scheduled and deduplicated.
func JoinScopes ¶ added in v0.12.1
JoinScopes combines several scope declarations into one value.
type Selector ¶
Selector chooses which DOM nodes an Indicators should target.
func SelectorQuery ¶
SelectorQuery selects the first element matching query.
func SelectorQueryAll ¶
SelectorQueryAll selects every element matching query.
func SelectorQueryParent ¶
SelectorQueryParent selects the closest ancestor matching query.
func SelectorTarget ¶
func SelectorTarget() Selector
SelectorTarget selects the element that triggered the event.
type SessionTracker ¶ added in v0.12.1
type SessionTracker = app.SessionTracker
SessionTracker observes session creation and deletion.
type Source ¶
type Source[T any] interface { Beam[T] // Route returns a renderable component that renders the first matching // writable route for this source. Route(routes ...RouteSource[T]) gox.EditorComp // Deprecated: Use Route RouteSource(routes ...RouteSource[T]) gox.EditorComp // Update sets a new value and propagates it to subscribers and derived // beams through the underlying source. Any context is allowed. Update(context.Context, T) // XUpdate behaves like [Source.Update] and returns a channel that reports // when propagation has finished. // // The channel receives nil on successful propagation or an error if the // context is invalid or the instance ends before propagation finishes. Do // not wait on it during rendering. If you need to wait, use [Go] or your // own goroutine with [Free]. XUpdate(context.Context, T) <-chan error // Mutate computes the next value from the current value and propagates it // through the underlying source. The function receives a copy of the // current value and must return the next value. Returning an unchanged copy // is a no-op when the underlying source treats the resulting parent value as // equal. Any context is allowed. Mutate(context.Context, func(T) T) // XMutate behaves like [Source.Mutate] and returns a channel that reports // when propagation has finished. // // The channel receives nil on successful propagation or an error if the // context is invalid or the instance ends before propagation finishes. Do // not wait on it during rendering. If you need to wait, use [Go] or your // own goroutine with [Free]. XMutate(context.Context, func(T) T) <-chan error // contains filtered or unexported methods }
Source is a writable reactive value.
A Source may be an original value owner created with NewSource or a derived view created with DeriveSource. Both forms can be read, subscribed to, routed, and updated. For reference types such as slices, maps, pointers, or mutable structs, replace the stored value instead of mutating it in place.
func DeriveSource ¶ added in v0.12.1
func DeriveSource[T1 any, T2 comparable](source Source[T1], get func(T1) T2, set func(T1, T2) T1) Source[T2]
DeriveSource derives a writable Source from source and uses `==` to suppress equal derived values.
get extracts the derived value from the source value. set receives the current source value and the new derived value and must return the next original source value.
Example:
settings := doors.NewSource(Settings{Units: "metric"})
units := doors.DeriveSource(settings,
func(s Settings) string { return s.Units },
func(s Settings, units string) Settings {
s.Units = units
return s
},
)
func DeriveSourceEqual ¶ added in v0.12.1
func DeriveSourceEqual[T1 any, T2 any](source Source[T1], get func(T1) T2, set func(T1, T2) T1, equal func(new T2, old T2) bool) Source[T2]
DeriveSourceEqual derives a writable Source from source with a custom equality function for the derived value.
equal should report whether new and old derived values should be treated as equal and therefore not propagated to this source's subscribers or derived beams. If equal is nil, every derived value propagates when the underlying source propagates.
func NewSource ¶
func NewSource[T comparable](init T) Source[T]
NewSource creates a Source that uses `==` to suppress equal updates.
Example:
count := doors.NewSource(0)
Example ¶
count := NewSource(1)
label := DeriveBeam(count, func(v int) string {
return fmt.Sprintf("count:%d", v)
})
fmt.Println(count.Get())
_ = label
Output: 1
func NewSourceEqual ¶
NewSourceEqual creates a Source with a custom equality function.
equal should report whether new and old should be treated as equal and therefore not propagated. If equal is nil, every update propagates.
func NewSourceEqualNoSkip ¶ added in v0.12.1
NewSourceEqualNoSkip creates a Source with a custom equality function and lets in-progress propagation finish even if a newer update arrives.
equal should report whether new and old should be treated as equal and therefore not propagated. If equal is nil, every update propagates.
func NewSourceNoSkip ¶ added in v0.12.1
func NewSourceNoSkip[T comparable](init T) Source[T]
NewSourceNoSkip creates a Source that uses `==` to suppress equal updates and lets in-progress propagation finish even if a newer update arrives.
type Store ¶
Store is goroutine-safe key-value storage used for session and instance data.
func InstanceStore ¶
InstanceStore returns storage scoped to the current instance only.
func SessionStore ¶
SessionStore returns storage shared by all instances in the current session.
type Use ¶
Use is HTTP middleware used by [App.Use].
func UseDir ¶ added in v0.12.1
UseDir serves files from a local directory under prefix.
prefix must not be "/" or empty. cacheControl is written on successful file responses when non-empty.
func UseFS ¶ added in v0.12.1
UseFS serves files from fsys under prefix.
prefix must not be "/" or empty. cacheControl is written on successful file responses when non-empty.
func UseFile ¶ added in v0.12.1
UseFile serves one local file at path.
path must not be "/" or empty. cacheControl is written on successful file responses when non-empty.
func UseResource ¶ added in v0.12.1
func UseResource(path string, resource ResourceStatic, contentType string) Use
UseResource serves a static Doors resource at path.
path must not be "/" or empty. contentType is passed to the resource registry and should describe the served resource, for example "text/css".
type With ¶ added in v0.12.1
type With interface {
// contains filtered or unexported methods
}
With configures NewApp.
func WithCSP ¶ added in v0.12.1
WithCSP enables Content-Security-Policy header generation for an app.
func WithESProfiles ¶ added in v0.12.1
func WithESProfiles(profile func(p string) api.BuildOptions) With
WithESProfiles sets the esbuild options provider used for script resources.
func WithErrorPage ¶ added in v0.12.1
WithErrorPage installs a custom app-level error page renderer.
func WithID ¶ added in v0.12.1
WithID sets the stable app id used for generated names and session cookies.
func WithSessionTracker ¶ added in v0.12.1
func WithSessionTracker(t SessionTracker) With
WithSessionTracker installs a session lifecycle observer.