type
HandlerOptions
HTTP security, size bounds, observers, and trusted-proxy policy.
Example
options := ridu.HandlerOptions{
SecureCookies: true,
AllowedHosts: []string{"cms.example.com"},
AllowedOrigins: []string{"https://app.example.com"},
RequestTimeout: 15 * time.Second,
}Properties
| Property | 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.
The zero value is development-friendly. Before production, set SecureCookies and AllowedHosts, add AllowedOrigins only for cross-origin browser clients, and trust only proxy ranges you operate. Body, request, readiness, worker, and maintenance bounds resolve independently when left at zero.