type
HandlerOptions
HTTP API, embedded admin, observability, security, and worker configuration.
Arguments
| Argument | Type | Description |
|---|---|---|
AdminAssets | fs.FS | Overrides the framework’s embedded admin asset filesystem. |
MaxBodyBytes | int64 | Limits decoded request bodies; zero uses the framework default. |
SecureCookies | bool | Restricts authentication cookies to HTTPS requests. |
AllowedOrigins | []string | Lists browser origins permitted by credentialed CORS. |
AllowedRequestHeaders | []string | Appends application-owned CORS request headers; invalid HTTP token names are ignored. |
AllowedHosts | []string | Restricts Host to exact hostnames with optional ports; empty accepts syntactically valid development hosts. |
TrustedProxyCIDRs | []string | Lists proxies whose forwarded client addresses may be trusted. |
TrustedProxyHops | int | TrustedProxyHops counts the proxies a request passes through, the one in TrustedProxyCIDRs that connects to Ridu included, when the others can't be listed. For a request from a trusted proxy, Ridu treats the last TrustedProxyHops-1 X-Forwarded-For addresses as proxies too and takes the client address from before them. Use it only when every proxy rewrites or appends to X-Forwarded-For, such as Railway's (2). Zero and one trust only TrustedProxyCIDRs; it has no effect without them. |
AuthRateLimit | int | Sets maximum auth attempts per identity and client window. |
AuthRateWindow | time.Duration | Sets the auth-attempt window. |
Audit | func(AuditEvent) | Receives security-relevant application events. |
Observe | func(RequestObservation) | Receives timing and status metadata for completed requests. |
RequestError | func(RequestErrorEvent) | Receives trusted diagnostic detail while public responses remain redacted. |
RequestTimeout | time.Duration | Limits request execution; zero uses the default and a negative value disables the bound. |
ReadinessChecks | []ReadinessCheck | Adds read-only repeatable dependencies to /readyz. |
ReadinessTimeout | time.Duration | Bounds the complete readiness probe; zero uses five seconds and a negative value disables it. |
ContentSecurityPolicy | string | Overrides the embedded admin CSP. |
DisableContentSecurityPolicy | bool | Disables CSP when an upstream gateway owns it. |
StrictTransportSecurity | string | Emits the configured HSTS value when every public request is HTTPS. |
TaskInterval | time.Duration | Controls durable-task polling frequency. |
TaskBatch | int | Limits leases claimed during one polling cycle. |
TaskQueues | []string | Restricts this process to named worker queues; empty consumes every queue. |
TaskLeaseDuration | time.Duration | Sets the lease extended while a handler runs. |
TaskHeartbeatInterval | time.Duration | Sets heartbeat cadence and must be shorter than the lease. |
TaskPruneBatch | int | Bounds expired terminal task records removed per cycle. |
AuthPruneBatch | int | Bounds expired sessions and API keys removed per maintenance cycle. |
JobError | func(error) | Receives failures from scheduled background work. |
How it works
Pass this value to App.Handler when embedding Ridu, or install it with WithHandlerOptions when Execute owns the server.
Full signature
type HandlerOptions struct {
// AdminAssets overrides the framework's embedded admin asset filesystem.
AdminAssets fs.FS
// MaxBodyBytes limits decoded request bodies. Zero uses the framework default.
MaxBodyBytes int64
// SecureCookies restricts auth cookies to HTTPS requests.
SecureCookies bool
// AllowedOrigins lists browser origins permitted by CORS.
AllowedOrigins []string
// AllowedRequestHeaders appends application-owned CORS request headers to
// Ridu's SDK headers. Invalid HTTP token names are ignored.
AllowedRequestHeaders []string
// AllowedHosts restricts the HTTP Host header. Entries are exact hostnames
// with an optional port; an entry without a port accepts any port. Empty
// accepts every syntactically valid host for development. Production
// deployments should set their public hostnames.
AllowedHosts []string
// TrustedProxyCIDRs lists proxies whose forwarded client addresses are trusted.
TrustedProxyCIDRs []string
// TrustedProxyHops counts the proxies a request passes through, the one
// in TrustedProxyCIDRs that connects to Ridu included, when the others
// can't be listed. For a request from a trusted proxy, Ridu treats the
// last TrustedProxyHops-1 X-Forwarded-For addresses as proxies too and
// takes the client address from before them. Use it only when every proxy
// rewrites or appends to X-Forwarded-For, such as Railway's (2). Zero and
// one trust only TrustedProxyCIDRs; it has no effect without them.
TrustedProxyHops int
// AuthRateLimit is the maximum auth attempts per identity and client window.
AuthRateLimit int
// AuthRateWindow is the duration over which AuthRateLimit is enforced.
AuthRateWindow time.Duration
// Audit receives security-relevant application events.
Audit func(AuditEvent)
// Observe receives timing and status metadata for completed requests.
Observe func(RequestObservation)
// RequestError receives trusted diagnostic detail for internal failures and
// recovered panics. The HTTP response remains redacted.
RequestError func(RequestErrorEvent)
// RequestTimeout limits request execution. Zero uses the framework default;
// a negative duration disables the handler deadline for streaming plugins.
RequestTimeout time.Duration
// ReadinessChecks add application/plugin dependencies to /readyz. Checks
// must be read-only, repeatable, and honor Context cancellation.
ReadinessChecks []ReadinessCheck
// ReadinessTimeout bounds the complete database, storage, and custom
// readiness probe. Zero uses five seconds; a negative duration disables it.
ReadinessTimeout time.Duration
// ContentSecurityPolicy overrides the framework admin policy. Empty uses a
// conservative default compatible with live-preview frames.
ContentSecurityPolicy string
// DisableContentSecurityPolicy explicitly disables the admin CSP when an
// upstream gateway owns it.
DisableContentSecurityPolicy bool
// StrictTransportSecurity is emitted verbatim when non-empty. Configure it
// only when every public request is HTTPS, normally at the TLS terminator.
StrictTransportSecurity string
// TaskInterval controls how often the durable task queues are polled. Zero
// uses the framework default.
TaskInterval time.Duration
// TaskBatch limits durable task leases claimed during one polling cycle.
TaskBatch int
// TaskQueues optionally restricts this process to named queues. An empty
// list consumes every queue, including unknown task slugs so they can be
// moved to a stable terminal failure.
TaskQueues []string
// TaskLeaseDuration is extended by heartbeats while a handler is running.
TaskLeaseDuration time.Duration
// TaskHeartbeatInterval must remain shorter than TaskLeaseDuration.
TaskHeartbeatInterval time.Duration
// TaskPruneBatch bounds terminal records removed after their retention.
TaskPruneBatch int
// AuthPruneBatch bounds expired sessions and API keys removed from each
// durable credential family during one background maintenance cycle.
AuthPruneBatch int
// JobError receives failures from scheduled background work.
JobError func(error)
// contains filtered or unexported fields
}Related types
AuditEventSecurity-relevant application event metadata.
RequestObservationTransport timing and response metadata for one completed request.
RequestErrorEventTrusted internal diagnostics for a failed request or recovered panic.
ReadinessCheckOne repeatable required-dependency readiness check.