Documentation
¶
Index ¶
- Constants
- Variables
- func AsBytes(s string) []byte
- func AsString(buf *[]byte) string
- func AttrsToMap(a gox.Attrs, logger *slog.Logger) map[string]string
- func EncodeId(b []byte) string
- func FreezeDequeBuffer(buffer *deque.Deque[any])
- func GetDequeBuffer() *deque.Deque[any]
- func GetGzipWriter(w io.Writer) *gzip.Writer
- func InitDefaults(s *Conf)
- func IterTags(tag reflect.StructTag) iter.Seq2[string, string]
- func Logger(ctx context.Context) *slog.Logger
- func MinifyCSS(input []byte) ([]byte, error)
- func NewJsonWriter(w io.Writer) io.Writer
- func NewRenderCtx(system context.Context, user context.Context) context.Context
- func PutDequeBuffer(buffer *deque.Deque[any])
- func PutGzipWriter(gz *gzip.Writer)
- func RandId() string
- func ReleaseDequeBuffer(buffer *deque.Deque[any])
- func UserCtx(ctx context.Context, parent context.Context) context.Context
- func Zip(input []byte) []byte
- type CSP
- type CSPCollector
- type Caller
- type Conf
- type EndCause
- type ID
- type OrderedMap
- type Prime
- type RenderCtx
- type Set
- type SolitaireConf
Constants ¶
const ( KeyCore ctxKey = iota KeySession KeyFrame KeyHistoryReplace )
const DefaultCacheControl string = "public, max-age=31536000, immutable"
DefaultCacheControl is the Cache-Control value used when ServerCacheControl is empty.
Variables ¶
Functions ¶
func FreezeDequeBuffer ¶ added in v0.13.19
func GetDequeBuffer ¶ added in v0.13.19
func InitDefaults ¶
func InitDefaults(s *Conf)
InitDefaults fills zero or invalid values in s with Doors defaults and applies the documented clamps.
func NewRenderCtx ¶ added in v0.15.0
func PutDequeBuffer ¶ added in v0.13.19
func PutGzipWriter ¶ added in v0.13.19
func ReleaseDequeBuffer ¶ added in v0.13.19
Types ¶
type CSP ¶
type CSP struct {
// DefaultSources are the default-src values. Nil emits 'self'; empty
// omits the directive.
DefaultSources []string
// ScriptSources are extra script-src values. The directive is always
// emitted with 'self', plus the import map hash and the URLs of
// doors.ResourceExternal scripts when the page has them.
ScriptSources []string
// ScriptStrictDynamic adds 'strict-dynamic' to script-src.
ScriptStrictDynamic bool
// StyleSources are extra style-src values. The directive is always emitted
// with 'self', plus the URLs of doors.ResourceExternal stylesheets when the
// page has them.
StyleSources []string
// ConnectSources are extra connect-src values. The directive is always
// emitted with 'self', which Doors needs for its own requests.
ConnectSources []string
// FormActions are the form-action values. Nil emits 'none'; empty omits
// the directive.
FormActions []string
// ObjectSources are the object-src values. Nil emits 'none'; empty omits
// the directive.
ObjectSources []string
// FrameSources are the frame-src values. Nil emits 'none'; empty omits
// the directive.
FrameSources []string
// FrameAncestors are the frame-ancestors values. Nil emits 'none'; empty
// omits the directive.
FrameAncestors []string
// BaseURIAllow are the base-uri values. Nil emits 'none'; empty omits the
// directive.
BaseURIAllow []string
// ImgSources are the img-src values. Nil or empty omits the directive.
ImgSources []string
// FontSources are the font-src values. Nil or empty omits the directive.
FontSources []string
// MediaSources are the media-src values. Nil or empty omits the directive.
MediaSources []string
// Sandbox are the sandbox flags. Nil or empty omits the directive.
Sandbox []string
// WorkerSources are the worker-src values. Nil or empty omits the
// directive.
WorkerSources []string
// ReportTo is the report-to group name. Empty omits the directive.
ReportTo string
}
CSP is the Content-Security-Policy Doors sends on page responses.
func (*CSP) NewCollector ¶
func (c *CSP) NewCollector() CSPCollector
NewCollector returns a collector for one page render. A nil c returns a nil collector.
type CSPCollector ¶
type CSPCollector = *cspCollector
CSPCollector collects the sources and hashes added while one page renders. A nil collector discards them.
func (CSPCollector) Generate ¶
func (c CSPCollector) Generate() string
Generate returns the final Content-Security-Policy header value.
func (CSPCollector) ScriptHash ¶
func (c CSPCollector) ScriptHash(hash []byte)
ScriptHash records an inline script hash for the final header.
func (CSPCollector) ScriptSource ¶
func (c CSPCollector) ScriptSource(source string)
ScriptSource records a script URL for the final header.
func (CSPCollector) StyleHash ¶
func (c CSPCollector) StyleHash(hash []byte)
StyleHash records an inline stylesheet hash for the final header.
func (CSPCollector) StyleSource ¶
func (c CSPCollector) StyleSource(source string)
StyleSource records a stylesheet URL for the final header.
type Caller ¶ added in v0.16.0
type Caller struct {
// contains filtered or unexported fields
}
func CaptureCaller ¶ added in v0.16.0
func CaptureCaller() Caller
type Conf ¶ added in v0.12.1
type Conf struct {
// SessionInstanceLimit is the max number of live page instances per
// session. Above it, the least active instance is suspended and reloads
// on the next interaction. Default: 12.
SessionInstanceLimit int
// SessionTTL is how long a session survives its last request. Values at
// or below InstanceTTL are raised to it.
SessionTTL time.Duration
// InstanceConnectTimeout is how long a rendered page has to connect back
// before its instance is dropped. Default: RequestTimeout.
InstanceConnectTimeout time.Duration
// InstanceGoroutineLimit is the max number of goroutines one page
// instance uses for rendering and reactive work. Default: 8.
InstanceGoroutineLimit int
// InstanceTTL is how long an instance is kept without a browser
// connection before it is dropped. Default: 40m; values below twice
// RequestTimeout are raised to that.
InstanceTTL time.Duration
// ServerCacheControl is the Cache-Control value for managed resources.
// Default: public, max-age=31536000, immutable.
ServerCacheControl string
// ServerDisableGzip disables gzip compression for HTML, Door updates, and
// managed resources.
ServerDisableGzip bool
// ServerDisableHead answers HEAD requests for pages with 405. By default a
// page HEAD renders the page to get its status and headers, and sends no
// body. Static files and resources always answer HEAD.
ServerDisableHead bool
// ServerSessionCookiePrefix is prepended to the Doors session cookie name.
// Use it for browser-enforced prefixes such as __Host- or __Secure-.
ServerSessionCookiePrefix string
// ServerRequestBodyLimit is the max size in bytes of a hook or form
// submission request body. Default: 8 MB.
ServerRequestBodyLimit int
// ServerSessionCookieNoSecure drops the Secure attribute from the cookies
// Doors sets. Use it only for plain HTTP development.
ServerSessionCookieNoSecure bool
// DisconnectHiddenTimer is how long a hidden page stays connected before it
// pauses; it reconnects when visible again. Default: InstanceTTL/2.
DisconnectHiddenTimer time.Duration
// RequestTimeout is the time limit of one request: page renders on the
// server, hook and navigation requests in the browser. Default: 30s.
RequestTimeout time.Duration
// SolitaireRollTime is how long one live connection request is held open
// before it is replaced by a fresh one. Lower it behind proxies that cut
// long requests. Default: 15s.
SolitaireRollTime time.Duration
// SolitaireSyncTimeout is how long the server waits for the browser to
// acknowledge an update before ending the instance. Default: InstanceTTL;
// larger values are capped at it.
SolitaireSyncTimeout time.Duration
// SolitaireFrameTime is how long outgoing updates are batched before they
// are sent to the browser. Default: 33.3ms.
SolitaireFrameTime time.Duration
// SolitaireFrameSize is how many buffered bytes force an immediate send of
// outgoing updates. Default: 32 KB.
SolitaireFrameSize int
// SolitaireDisableGzip disables gzip compression of action payloads sent
// to the browser.
SolitaireDisableGzip bool
// SolitaireQueue is the max number of updates waiting for delivery or
// acknowledgement. Exceeding it ends the instance. Default: 1024.
SolitaireQueue int
// SolitairePending is the max number of delivered but unacknowledged
// updates; at the limit the server stops sending. Default: 256.
SolitairePending int
// SolitaireDisableReportStreaming makes the browser post each message
// separately instead of streaming one request body. The browser already
// falls back on its own outside HTTP/2 and HTTP/3.
SolitaireDisableReportStreaming bool
// SolitaireReportLimit is the max size in bytes of one message the browser
// sends back. Default: 8 MB.
SolitaireReportLimit int
// SolitaireReportTimeout is how long the server waits to receive one
// message from the browser before dropping the connection. Default: 5s, or
// SolitaireRollTime if it is smaller.
SolitaireReportTimeout time.Duration
// SolitaireMaxRTT caps the round-trip estimate used to pace waiting on the
// browser while updates are unacknowledged. Values below twice
// SolitaireFrameTime are raised to that. Default: 1s.
SolitaireMaxRTT time.Duration
}
Conf is the Doors runtime configuration.
type OrderedMap ¶ added in v0.12.1
func (*OrderedMap[K, V]) Delete ¶ added in v0.12.1
func (s *OrderedMap[K, V]) Delete(k K) bool
func (*OrderedMap[K, V]) Get ¶ added in v0.12.1
func (s *OrderedMap[K, V]) Get(k K) (V, bool)
func (OrderedMap[K, V]) Iter ¶ added in v0.12.1
func (s OrderedMap[K, V]) Iter() iter.Seq2[K, V]
func (OrderedMap[K, V]) Len ¶ added in v0.12.1
func (s OrderedMap[K, V]) Len() int
func (*OrderedMap[K, V]) Set ¶ added in v0.12.1
func (s *OrderedMap[K, V]) Set(k K, v V)
type RenderCtx ¶ added in v0.15.0
type RenderCtx struct {
// contains filtered or unexported fields
}
type SolitaireConf ¶
type SolitaireConf struct {
// Roll is the effective SolitaireRollTime.
Roll time.Duration
// FrameSize is the effective SolitaireFrameSize.
FrameSize int
// FlushTime is the effective SolitaireFrameTime.
FlushTime time.Duration
// DisableGzip is the effective SolitaireDisableGzip.
DisableGzip bool
// DisableReportStreaming is the effective SolitaireDisableReportStreaming.
DisableReportStreaming bool
// Queue is the effective SolitaireQueue.
Queue int
// Pending is the effective SolitairePending.
Pending int
// SyncTimeout is the effective SolitaireSyncTimeout.
SyncTimeout time.Duration
// ReportSize is the effective SolitaireReportLimit.
ReportSize int
// ReportTimeout is the effective SolitaireReportTimeout.
ReportTimeout time.Duration
// MaxRTT is the effective SolitaireMaxRTT.
MaxRTT time.Duration
}
SolitaireConf holds the effective update stream settings taken from Conf.
func GetSolitaireConf ¶
func GetSolitaireConf(s *Conf) *SolitaireConf
GetSolitaireConf returns the effective update stream settings of s.