Documentation
¶
Index ¶
- Constants
- func AsBytes(s string) []byte
- func AsString(buf *[]byte) string
- func AttrsToMap(a gox.Attrs) map[string]string
- func Catch(f func()) (err error)
- func CatchValue[V any](f func() V) (value V, err error)
- func EncodeId(b []byte) string
- func Hash(input []byte) string
- func InitDefaults(s *SystemConf)
- func MinifyCSS(input []byte) ([]byte, error)
- func NewJsonWriter(w io.Writer) io.Writer
- func RandId() string
- func Ts()
- func Zip(input []byte) ([]byte, error)
- type CSP
- type CSPCollector
- type EndCause
- type ID
- type Prime
- type Set
- type SolitaireConf
- type SystemConf
Constants ¶
const DefaultCacheControl string = "public, max-age=31536000, immutable"
Variables ¶
This section is empty.
Functions ¶
func CatchValue ¶
func InitDefaults ¶
func InitDefaults(s *SystemConf)
InitDefaults fills zero or invalid values in s with Doors defaults.
Types ¶
type CSP ¶
type CSP struct {
// default-src:
// nil ⇒ emit: default-src 'self'
// len == 0 ⇒ omit: (no default-src directive)
// len > 0 ⇒ emit: default-src <values>
DefaultSources []string
// script-src (user additions only):
// Directive is ALWAYS emitted with at least 'self' plus any collected hashes/sources.
// nil or len == 0 ⇒ no extra user sources added.
ScriptSources []string
// script-src strict-dynamic:
// When true, appends 'strict-dynamic' to script-src (typically used with nonces/hashes).
ScriptStrictDynamic bool
// style-src (user additions only):
// Directive is ALWAYS emitted with at least 'self' plus any collected hashes/sources.
// nil or len == 0 ⇒ no extra user sources added.
StyleSources []string
// connect-src (user additions only):
// Directive is ALWAYS emitted with at least 'self'.
// nil or len == 0 ⇒ results in: connect-src 'self'
// len > 0 ⇒ connect-src 'self' <values>
ConnectSources []string
// form-action:
// nil ⇒ emit: form-action 'none'
// len == 0 ⇒ omit: (no form-action directive)
// len > 0 ⇒ emit: form-action <values>
FormActions []string
// object-src:
// nil ⇒ emit: object-src 'none'
// len == 0 ⇒ omit: (no object-src directive)
// len > 0 ⇒ emit: object-src <values>
ObjectSources []string
// frame-src:
// nil ⇒ emit: frame-src 'none'
// len == 0 ⇒ omit: (no frame-src directive)
// len > 0 ⇒ emit: frame-src <values>
FrameSources []string
// frame-ancestors:
// nil ⇒ emit: frame-ancestors 'none'
// len == 0 ⇒ omit: (no frame-ancestors directive)
// len > 0 ⇒ emit: frame-ancestors <values>
FrameAcestors []string
// base-uri:
// nil ⇒ emit: base-uri 'none'
// len == 0 ⇒ omit: (no base-uri directive)
// len > 0 ⇒ emit: base-uri <values>
BaseURIAllow []string
// img-src:
// nil or len == 0 ⇒ omit
// len > 0 ⇒ emit: img-src <values>
ImgSources []string
// font-src:
// nil or len == 0 ⇒ omit
// len > 0 ⇒ emit: font-src <values>
FontSources []string
// media-src:
// nil or len == 0 ⇒ omit
// len > 0 ⇒ emit: media-src <values>
MediaSources []string
// sandbox:
// nil or len == 0 ⇒ omit
// len > 0 ⇒ emit: sandbox <flags>
Sandbox []string
// worker-src:
// nil or len == 0 ⇒ omit
// len > 0 ⇒ emit: worker-src <values>
WorkerSources []string
// report-to:
// "" ⇒ omit
// set ⇒ emit: report-to <value>
// NOTE: To make this effective, you must also send a corresponding
// `Report-To` HTTP response header that defines the reporting group.
ReportTo string
}
CSP configures the Content-Security-Policy header generated by Doors.
Nil and empty slices have different meanings for several directives, as noted on each field.
func (*CSP) NewCollector ¶
func (c *CSP) NewCollector() *CSPCollector
NewCollector creates a per-response collector for c.
type CSPCollector ¶
type CSPCollector struct {
// contains filtered or unexported fields
}
CSPCollector accumulates hashes and dynamic sources that should be added to a CSP during one response.
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 CSP header.
func (*CSPCollector) ScriptSource ¶
func (c *CSPCollector) ScriptSource(source string)
ScriptSource records a dynamic script source for the final CSP header.
func (*CSPCollector) StyleHash ¶
func (c *CSPCollector) StyleHash(hash []byte)
StyleHash records an inline stylesheet hash for the final CSP header.
func (*CSPCollector) StyleSource ¶
func (c *CSPCollector) StyleSource(source string)
StyleSource records a dynamic stylesheet source for the final CSP header.
type SolitaireConf ¶
type SolitaireConf struct {
Ping time.Duration
FlushSize int
RollDuration time.Duration
FlushTimeout time.Duration
DisableGzip bool
Queue int
Pending int
SyncTimeout time.Duration
}
func GetSolitaireConf ¶
func GetSolitaireConf(s *SystemConf) *SolitaireConf
type SystemConf ¶
type SystemConf struct {
// SessionInstanceLimit is the max number of page instances per session.
// When exceeded, the oldest inactive ones are suspended.
// Default: 12.
SessionInstanceLimit int
// SessionTTL controls how long session lives after last activity.
// Default behavior (value 0): InstanceTTL
SessionTTL time.Duration
// InstanceConnectTimeout controls how long new instance waits
// before shutdown for the first client connection.
// Default: RequestTimeout
InstanceConnectTimeout time.Duration
// InstanceGoroutineLimit is the max goroutines per page instance.
// Controls resource use for rendering and reactive updates. Default: 16.
InstanceGoroutineLimit int
// InstanceTTL is how long an inactive instance is kept before cleanup.
// Active = browser connected. Default: 40minutes.
InstanceTTL time.Duration
// ServerCacheControl defines cache control header value for JS and CSS
// resources prepared by the framework.
// Default "public, max-age=31536000, immutable"
ServerCacheControl string
// ServerDisableGzip disables gzip compression for HTML, JS, and CSS if true.
ServerDisableGzip bool
// DisconnectHiddenTimer is how long hidden/background instances stay connected.
// Default: InstanceTTL/2.
DisconnectHiddenTimer time.Duration
// RequestTimeout is the max duration of a client-server request.
// Default: 30s.
RequestTimeout time.Duration
// SolitairePing is the max time before rolling the request.
// Default: 15s.
SolitairePing time.Duration
// SolitaireSyncTimeout is the max pending duration of a server→client sync task,
// including user calls. Exceeding this kills the instance.
// Default: InstanceTTL.
SolitaireSyncTimeout time.Duration
// SolitaireRollTimeout is how long an active sync connection lasts before
// rolling to a new one if the queue is long. Default: 1s.
SolitaireRollTimeout time.Duration
// SolitaireFlushTimeout is the max time before forcing a flush.
// Default: 30ms
SolitaireFlushTimeout time.Duration
// SolitaireFlushSizeLimit is the max buffered bytes before forcing a flush.
// Default: 32 KB
SolitaireFlushSizeLimit int
// SolitaireDisableGzip disables gzip compression for solitaire sync payloads if true.
SolitaireDisableGzip bool
// SolitaireQueue is the max queued server→client sync task.
// Exceeding this kills the instance. Default: 1024.
SolitaireQueue int
// SolitairePending is the max unresolved server→client sync tasks.
// Throttles sending when reached. Default: 256.
SolitairePending int
}
SystemConf defines global configuration for sessions, instances, client-server communication, and performance. Defaults are auto-initialized.