doors

package module
v0.12.3 Latest Latest
Warning

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

Go to latest
Published: May 9, 2026 License: Apache-2.0 Imports: 31 Imported by: 0

README

Doors

codecov Go Report Card Go Reference Mentioned in Awesome Go

https://doors.dev

Doors is a server-driven UI framework + runtime for building stateful, reactive web applications in Go.

Recent Version

Doors 0.12 is a broad release with migration-impacting changes compared with 0.8.x-0.10.x.

Read the release notes for the overview.

If you are upgrading existing code or asking an agent to migrate it, start with the migration guide.

Example

type Search struct {
    input doors.Source[string] // reactive state
}

elem (s Search) Main() {
    <input
        (doors.AInput{
            On: func(ctx context.Context, r doors.RequestInput) bool {
                s.input.Update(ctx, r.Event().Value) // update state
                return false
            },
        })
        type="text"
        placeholder="search">

    ~(s.input.Bind(s.results)) // bind results to state changes
}

elem (s Search) results(input string) {
    ~(for _, user := range Users.Search(input) {
        <card>
            ~(user.Name)
        </card>
    })
}

Some highlights

  • Front-end framework capabilities in server-side Go. Reactive state primitives, dynamic routing, composable components.
  • No public API layer. No endpoint design needed, private temporal transport is handled under the hood.
  • Unified control flow. No context switch between back-end/front-end.
  • Integrated web stack. Bundle assets, build scripts, serve private files, automate CSP, and ship in one binary.

Execution model

Go server is UI runtime: web application runs on a stateful server, while the browser acts as a remote renderer and input layer.

Mental model

Link DOM to the data it depends on.

Peculiarities

  • Purposely build Go language extension with its own LSP, parser, and editor plugins. Adds HTML as Go expressions and elem primitives.
  • Reactive state primitives that can be subscribed to, derived, and mutated.
  • Dynamic containers that can be updated, replaced, or removed at runtime.
  • Type-safe routing with URLs represented as Go structs.
  • HTTP/3-ready synchronization protocol (rolling-request + streaming, events via regular post, no WebSockets/SSE).
  • Custom concurrency engine that enables non-blocking event processing, parallel rendering, and tree-aware state propagation.
  • Secure by default: every user can interact only with what you render to them. Means you check permissions when your render the button and that's is enough to be sure that related action wont be triggered by anyone else.

Where Doors fits best

  • SaaS products
  • Business systems
  • Customer portals
  • Admin panels
  • Internal tools
  • Real-time apps with meaningful server-side workflows

Where it is not the right fit

  • Static or mostly non-interactive sites
  • Client-first apps with minimal server behavior and simple routing
  • Offline-first PWAs where the browser must be the primary runtime

Comparisons

Doors vs HTMX

HTMX enhances HTML by coordinating behavior through attributes and endpoints. Doors is a UI runtime: you write the interaction flow directly in Go and let the runtime handle synchronization.

Doors vs React, Next.js, and similar stacks

Typical JavaScript stacks place much of the interaction model in the browser while the server acts mainly as a data service. Doors keeps that flow on the server in Go, with the browser focused on display and input.

Learn more

Status

Doors is in beta. It is ready for development and can be used in production with caution, but you should expect fixes and updates as the ecosystem matures.

Licensing

Doors is licensed under the Apache License 2.0.

See also:

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

Examples

Constants

View Source
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

View Source
var DocsFS embed.FS

DocsFS is the embedded documentation tree.

Functions

func Call

func Call(ctx context.Context, action Action)

Call dispatches action to the client without waiting for a result.

Canceling ctx requests best-effort cancellation of the call.

func Free

func Free(ctx context.Context) context.Context

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

func FreeRoot(ctx context.Context) context.Context

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

func Go(f func(context.Context)) gox.Editor

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 IDBytes

func IDBytes(b []byte) string

IDBytes returns a stable URL-safe identifier derived from b.

func IDRand

func IDRand() string

IDRand returns a cryptographically secure, URL-safe identifier.

func IDString

func IDString(string string) string

IDString returns a stable URL-safe identifier derived from string.

func InstanceEnd

func InstanceEnd(ctx context.Context)

InstanceEnd ends the current instance (tab/window) but keeps the session and other instances active.

func InstanceId

func InstanceId(ctx context.Context) string

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

func Parallel() gox.Proxy

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

func ProxyMod(mod gox.Modify) gox.Proxy

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

func Reload(ctx context.Context)

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

func SessionEnd(ctx context.Context)

SessionEnd immediately ends the current session and all instances. Use it during logout to close authorized pages and free server resources.

func SessionExpire

func SessionExpire(ctx context.Context, d time.Duration)

SessionExpire sets the maximum lifetime of the current session.

func SessionId

func SessionId(ctx context.Context) string

SessionId returns the unique ID of the current session. All instances in the same browser share this ID via a session cookie.

func Status

func Status(statusCode int) gox.Editor

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

func XReload(ctx context.Context) <-chan error

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.

func (ABlur) Modify

func (b ABlur) Modify(ctx context.Context, _ string, attrs gox.Attrs) error

func (ABlur) Proxy

func (b ABlur) Proxy(cur gox.Cursor, elem gox.Elem) error

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.

func (AChange) Modify

func (p AChange) Modify(ctx context.Context, _ string, attrs gox.Attrs) error

func (AChange) Proxy

func (p AChange) Proxy(cur gox.Cursor, elem gox.Elem) error

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.

func (AClick) Modify

func (p AClick) Modify(ctx context.Context, _ string, attrs gox.Attrs) error

func (AClick) Proxy

func (p AClick) Proxy(cur gox.Cursor, elem gox.Elem) error

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

func (AData) Modify

func (a AData) Modify(ctx context.Context, _ string, attrs gox.Attrs) error

func (AData) Proxy

func (a AData) Proxy(cur gox.Cursor, elem gox.Elem) error

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.

func (AFocus) Modify

func (f AFocus) Modify(ctx context.Context, _ string, attrs gox.Attrs) error

func (AFocus) Proxy

func (f AFocus) Proxy(cur gox.Cursor, elem gox.Elem) error

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.

func (AFocusIn) Modify

func (f AFocusIn) Modify(ctx context.Context, _ string, attrs gox.Attrs) error

func (AFocusIn) Proxy

func (f AFocusIn) Proxy(cur gox.Cursor, elem gox.Elem) error

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.

func (AFocusOut) Modify

func (f AFocusOut) Modify(ctx context.Context, _ string, attrs gox.Attrs) error

func (AFocusOut) Proxy

func (f AFocusOut) Proxy(cur gox.Cursor, elem gox.Elem) error

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.

func (AGotPointerCapture) Modify

func (p AGotPointerCapture) Modify(ctx context.Context, _ string, attrs gox.Attrs) error

func (AGotPointerCapture) Proxy

func (p AGotPointerCapture) Proxy(cur gox.Cursor, elem gox.Elem) error

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.

func (AHook[T]) Modify

func (h AHook[T]) Modify(ctx context.Context, _ string, attrs gox.Attrs) error

func (AHook[T]) Proxy

func (h AHook[T]) Proxy(cur gox.Cursor, elem gox.Elem) error

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.

func (AInput) Modify

func (p AInput) Modify(ctx context.Context, _ string, attrs gox.Attrs) error

func (AInput) Proxy

func (p AInput) Proxy(cur gox.Cursor, elem gox.Elem) error

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.

func (AKeyDown) Modify

func (k AKeyDown) Modify(ctx context.Context, _ string, attrs gox.Attrs) error

func (AKeyDown) Proxy

func (k AKeyDown) Proxy(cur gox.Cursor, elem gox.Elem) error

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.

func (AKeyUp) Modify

func (k AKeyUp) Modify(ctx context.Context, _ string, attrs gox.Attrs) error

func (AKeyUp) Proxy

func (k AKeyUp) Proxy(cur gox.Cursor, elem gox.Elem) error
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},
})

func (ALink) Modify

func (h ALink) Modify(ctx context.Context, _ string, attrs gox.Attrs) error

func (ALink) Proxy

func (h ALink) Proxy(cur gox.Cursor, elem gox.Elem) error

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.

func (ALostPointerCapture) Modify

func (p ALostPointerCapture) Modify(ctx context.Context, _ string, attrs gox.Attrs) error

func (ALostPointerCapture) Proxy

func (p ALostPointerCapture) Proxy(cur gox.Cursor, elem gox.Elem) error

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.

func (APointerCancel) Modify

func (p APointerCancel) Modify(ctx context.Context, _ string, attrs gox.Attrs) error

func (APointerCancel) Proxy

func (p APointerCancel) Proxy(cur gox.Cursor, elem gox.Elem) error

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.

func (APointerDown) Modify

func (p APointerDown) Modify(ctx context.Context, _ string, attrs gox.Attrs) error

func (APointerDown) Proxy

func (p APointerDown) Proxy(cur gox.Cursor, elem gox.Elem) error

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.

func (APointerEnter) Modify

func (p APointerEnter) Modify(ctx context.Context, _ string, attrs gox.Attrs) error

func (APointerEnter) Proxy

func (p APointerEnter) Proxy(cur gox.Cursor, elem gox.Elem) error

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.

func (APointerLeave) Modify

func (p APointerLeave) Modify(ctx context.Context, _ string, attrs gox.Attrs) error

func (APointerLeave) Proxy

func (p APointerLeave) Proxy(cur gox.Cursor, elem gox.Elem) error

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.

func (APointerMove) Modify

func (p APointerMove) Modify(ctx context.Context, _ string, attrs gox.Attrs) error

func (APointerMove) Proxy

func (p APointerMove) Proxy(cur gox.Cursor, elem gox.Elem) error

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.

func (APointerOut) Modify

func (p APointerOut) Modify(ctx context.Context, _ string, attrs gox.Attrs) error

func (APointerOut) Proxy

func (p APointerOut) Proxy(cur gox.Cursor, elem gox.Elem) error

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.

func (APointerOver) Modify

func (p APointerOver) Modify(ctx context.Context, _ string, attrs gox.Attrs) error

func (APointerOver) Proxy

func (p APointerOver) Proxy(cur gox.Cursor, elem gox.Elem) error

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.

func (APointerUp) Modify

func (p APointerUp) Modify(ctx context.Context, _ string, attrs gox.Attrs) error

func (APointerUp) Proxy

func (p APointerUp) Proxy(cur gox.Cursor, elem gox.Elem) error

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.

func (ARawHook) Modify

func (h ARawHook) Modify(ctx context.Context, _ string, attrs gox.Attrs) error

func (ARawHook) Proxy

func (h ARawHook) Proxy(cur gox.Cursor, elem gox.Elem) error

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.

func (ARawSubmit) Modify

func (s ARawSubmit) Modify(ctx context.Context, _ string, attrs gox.Attrs) error

func (ARawSubmit) Proxy

func (s ARawSubmit) Proxy(cur gox.Cursor, elem gox.Elem) error

type AShared

type AShared = *aShared

AShared is a reusable dynamic attribute handle shared across every element it is attached to.

func NewAShared

func NewAShared(name string, value string) AShared

NewAShared returns an enabled shared attribute handle.

Update, Enable, and Disable affect every attached element together.

func (AShared) Disable

func (a AShared) Disable(ctx context.Context)

Disable removes the attribute from attached elements.

func (AShared) Enable

func (a AShared) Enable(ctx context.Context)

Enable adds the attribute to attached elements.

func (AShared) Modify

func (a AShared) Modify(ctx context.Context, _ string, attrs gox.Attrs) error

func (AShared) Proxy

func (a AShared) Proxy(cur gox.Cursor, elem gox.Elem) error

func (AShared) Update

func (a AShared) Update(ctx context.Context, value string)

Update sets the attribute's value.

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.

func (ASubmit[V]) Modify

func (s ASubmit[V]) Modify(ctx context.Context, _ string, attrs gox.Attrs) error

func (ASubmit[V]) Proxy

func (s ASubmit[V]) Proxy(cur gox.Cursor, elem gox.Elem) error

type Action

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

Action performs a client-side operation.

type ActionEmit

type ActionEmit struct {
	Name string
	Arg  any
}

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

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

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

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

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

func JoinActions(values ...Actions) Actions

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)
	http.Handler
}

App is a Doors application and HTTP handler.

func NewApp added in v0.12.1

func NewApp(page func(ctx context.Context, r Request) gox.Comp, options ...With) App

NewApp creates a Doors HTTP handler from the root page function.

The page function receives the Doors runtime context and request helpers, and returns the component to render for the current request.

type Attr

type Attr interface {
	gox.Modify
	gox.Proxy
}

Attr is a Doors attribute modifier that can be attached directly to an element or applied through a proxy component.

func A

func A(ctx context.Context, a ...Attr) Attr

A combines one or more Attr values into a single modifier.

Example:

attrs := doors.A(ctx,
	doors.AClick{On: onClick},
	doors.AData{Name: "user", Value: user},
)

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 CSP

type CSP = common.CSP

CSP is the Content-Security-Policy configuration.

type CallResult

type CallResult[T any] struct {
	Ok  T     // Result value
	Err error // Error if the call failed
}

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

func Class(classes ...string) Classes

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

func (c Classes) Add(classes ...string) Classes

Add returns a new Classes value with classes appended.

Arguments are split like Class, so Add("a", "b c") adds three classes.

func (Classes) Clone added in v0.9.7

func (c Classes) Clone() Classes

Clone returns an independent copy of c.

func (Classes) Filter added in v0.9.7

func (c Classes) Filter(classes ...string) Classes

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

func (c Classes) Join(classes ...Classes) Classes

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) Modify added in v0.9.7

func (c Classes) Modify(ctx context.Context, tag string, atts gox.Attrs) error

func (Classes) Mutate added in v0.9.7

func (c Classes) Mutate(name string, prev any) any

func (Classes) Output added in v0.9.7

func (c Classes) Output(w io.Writer) error

func (Classes) Proxy added in v0.9.7

func (c Classes) Proxy(cur gox.Cursor, el gox.Elem) error

func (Classes) Remove added in v0.9.7

func (c Classes) Remove(classes ...string) Classes

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.

func (Classes) String added in v0.9.7

func (c Classes) String() string

String returns the class list as it would be rendered in a class attribute.

type Conf added in v0.12.1

type Conf = common.Conf

Conf is the Doors runtime configuration.

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

type Door = door.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.

func (ESProfile) Profile added in v0.12.1

func (opt ESProfile) Profile(string) api.BuildOptions

Profile returns esbuild options for a named profile.

type ErrorPage added in v0.12.1

type ErrorPage = app.ErrorPage

ErrorPage renders an app-level error response.

type FocusEvent

type FocusEvent = front.FocusEvent

FocusEvent is the payload sent to focus event handlers.

type Indicator

type Indicator = front.Indicator

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

func JSXPreact

func JSXPreact() JSX

JSXPreact returns JSX settings suitable for classic Preact transforms.

func JSXReact

func JSXReact() JSX

JSXReact returns JSX settings suitable for React's automatic runtime.

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

type Location = path.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

func NewLocation(model any) (Location, error)

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

type LocationEncoder = path.Encoder

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

func ResourceProxy(url string) Resource

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

func RouteDefaultBeam[T any, C gox.Comp](render func(Beam[T]) C) RouteBeam[T]

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

func RouteDefaultComp[T any](comp gox.Comp) RouteBeam[T]

RouteDefaultComp creates a fallback route that always matches and renders comp.

func RouteLocationDefaultBeam added in v0.12.1

func RouteLocationDefaultBeam[C gox.Comp](render func(Beam[Location]) C) RouteBeam[Location]

RouteLocationDefaultBeam creates a fallback URL route that renders a read-only beam for the current Location.

func RouteLocationDefaultComp added in v0.12.1

func RouteLocationDefaultComp(comp gox.Comp) RouteBeam[Location]

RouteLocationDefaultComp creates a fallback URL route that renders comp.

func RouteModelBeam added in v0.12.1

func RouteModelBeam[M any, C gox.Comp](render func(Beam[M]) C) RouteBeam[Location]

RouteModelBeam creates a URL route for path model M and renders a read-only beam for the decoded model.

The route matches when the current Location decodes into M.

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 RouteDefaultSource added in v0.12.1

func RouteDefaultSource[T any, C gox.Comp](render func(Source[T]) C) RouteSource[T]

RouteDefaultSource creates a fallback route that always matches and renders a writable source for the full routed value.

func RouteLocationDefaultSource added in v0.12.1

func RouteLocationDefaultSource[C gox.Comp](render func(Source[Location]) C) RouteSource[Location]

RouteLocationDefaultSource creates a fallback URL route that renders a writable source for the current Location.

func RouteModel added in v0.12.3

func RouteModel[M any, C gox.Comp](render func(Source[M]) C) RouteSource[Location]

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

func RouteModelSource[M any, C gox.Comp](render func(Source[M]) C) RouteSource[Location]

Deprecated: Use RouteModel

type Scope

type Scope = front.Scope

Scope is the low-level client scheduling scope used by event hooks.

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

func (*ScopeBlocking) Scopes added in v0.12.1

func (sb *ScopeBlocking) Scopes(core core.Core) []Scope

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

func (*ScopeDebounce) Scopes added in v0.12.1

func (s *ScopeDebounce) Scopes(core core.Core) []Scope

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

func (*ScopeLatest) Scopes added in v0.12.1

func (s *ScopeLatest) Scopes(core core.Core) []Scope

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

func (*ScopeSerial) Scopes added in v0.12.1

func (ss *ScopeSerial) Scopes(core core.Core) []Scope

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

func JoinScopes(values ...Scopes) Scopes

JoinScopes combines several scope declarations into one value.

type Selector

type Selector = front.Selector

Selector chooses which DOM nodes an Indicators should target.

func SelectorQuery

func SelectorQuery(query string) Selector

SelectorQuery selects the first element matching query.

func SelectorQueryAll

func SelectorQueryAll(query string) Selector

SelectorQueryAll selects every element matching query.

func SelectorQueryParent

func SelectorQueryParent(query string) Selector

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]

	// RouteSource returns a renderable component that renders the first matching
	// writable route for this source.
	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

func NewSourceEqual[T any](init T, equal func(new T, old T) bool) Source[T]

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

func NewSourceEqualNoSkip[T any](init T, equal func(new T, old T) bool) Source[T]

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.

func Router

func Router(ctx context.Context) Source[Location]

Router returns the current instance URL as a writable reactive source.

Updating the returned source changes the browser location and reroutes the current page.

type Store

type Store = ctex.Store

Store is goroutine-safe key-value storage used for session and instance data.

func InstanceStore

func InstanceStore(ctx context.Context) Store

InstanceStore returns storage scoped to the current instance only.

func SessionStore

func SessionStore(ctx context.Context) Store

SessionStore returns storage shared by all instances in the current session.

type Use

type Use = func(http.Handler) http.Handler

Use is HTTP middleware used by [App.Use].

func UseDir added in v0.12.1

func UseDir(prefix string, dirPath string, cacheControl string) Use

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

func UseFS(prefix string, fsys fs.FS, cacheControl string) Use

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

func UseFile(path string, filePath string, cacheControl string) Use

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 Watcher added in v0.9.8

type Watcher[T any] = beam.Watcher[T]

Watcher receives low-level Beam update callbacks.

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

func WithCSP(csp CSP) With

WithCSP enables Content-Security-Policy header generation for an app.

func WithConf added in v0.12.1

func WithConf(conf Conf) With

WithConf applies runtime configuration to 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

func WithErrorPage(ep ErrorPage) With

WithErrorPage installs a custom app-level error page renderer.

func WithID added in v0.12.1

func WithID(id string) With

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.

Jump to

Keyboard shortcuts

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