app

package
v0.15.0-dev.30 Latest Latest
Warning

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

Go to latest
Published: Aug 26, 2026 License: Apache-2.0 Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type App

type App = *app

App is a Doors application and HTTP handler.

func NewApp

func NewApp(page Page, o Options) App

NewApp returns an App that serves page, configured by o.

func (App) CSP

func (a App) CSP() *common.CSP

func (App) Drain added in v0.13.6

func (a App) Drain(callback func())

func (App) Draining added in v0.13.6

func (a App) Draining() bool

func (App) InstanceCount added in v0.12.8

func (a App) InstanceCount() int

func (App) InstanceCreated added in v0.13.6

func (a App) InstanceCreated()

func (App) InstanceDeleted added in v0.13.6

func (a App) InstanceDeleted()

func (App) PathMaker

func (a App) PathMaker() path.PathMaker

func (App) RemoveSession

func (a App) RemoveSession(id string)

func (App) Resources

func (a App) Resources() resources.Registry

func (App) ServeHTTP

func (a App) ServeHTTP(w http.ResponseWriter, r *http.Request)

func (App) SessionCount added in v0.12.8

func (a App) SessionCount() (n int)

type ErrorPage

type ErrorPage = func(r *http.Request, err error) gox.Elem

ErrorPage renders the body of an app-level error response.

type Middleware

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

Middleware wraps the app handler.

type Options

type Options struct {
	// Conf is the runtime configuration from doors.WithConf.
	Conf common.Conf
	// CSP is the policy from doors.WithCSP. Nil sends no header.
	CSP *common.CSP
	// ESBuild is the esbuild options provider from doors.WithESProfiles.
	ESBuild func(profile string) api.BuildOptions
	// SessionTrackers are the observers from doors.WithSessionTracker, in
	// registration order.
	SessionTrackers []SessionTracker
	// ID is the app id from doors.WithID. Default: doors.
	ID string
	// CookieName is the app id cookie name from doors.WithIDCookie. Empty
	// sets no cookie.
	CookieName string
	// ErrorPage is the error renderer from doors.WithErrorPage.
	ErrorPage ErrorPage
	// Logger is the logger from doors.WithLogger. Nil uses slog.Default().
	Logger *slog.Logger
	// PrinterMiddleware is the printer wrapper from doors.WithPrinter. Nil
	// disables wrapping.
	PrinterMiddleware func(next gox.Printer) gox.Printer
}

Options is the resolved set of app options.

type Page

type Page = instance.Page

Page is the page factory called once per page instance.

type SessionTracker

type SessionTracker interface {
	// Create runs when a session is created, before the request that
	// triggered it is served. r must not be retained past the call and its
	// body must not be read.
	Create(id string, r *http.Request)

	// Delete runs at most once per session, when it is removed.
	Delete(id string)
}

SessionTracker observes session creation and removal.

Jump to

Keyboard shortcuts

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