PolicyDefinition
Defined in: src/policies/sdk/define-policy.ts:35
Declarative policy definition passed to definePolicy.
Type Parameters
Section titled “Type Parameters”TConfig
Section titled “TConfig”TConfig extends PolicyConfig = PolicyConfig
Properties
Section titled “Properties”defaults?
Section titled “defaults?”
optionaldefaults:Partial<TConfig>
Defined in: src/policies/sdk/define-policy.ts:43
Default values for optional config fields.
handler()
Section titled “handler()”handler: (
c,next,ctx) =>void|Promise<void>
Defined in: src/policies/sdk/define-policy.ts:56
The policy handler. Receives the Hono context, next, and a
PolicyHandlerContext with config, debug, and gateway context.
Parameters
Section titled “Parameters”Context
Next
PolicyHandlerContext<TConfig>
Returns
Section titled “Returns”void | Promise<void>
name:
string
Defined in: src/policies/sdk/define-policy.ts:39
Unique policy name (e.g. "my-auth", "custom-cache").
priority?
Section titled “priority?”
optionalpriority:number
Defined in: src/policies/sdk/define-policy.ts:41
Execution priority. Use Priority constants. Default: Priority.DEFAULT (100).
validate()?
Section titled “validate()?”
optionalvalidate: (config) =>void
Defined in: src/policies/sdk/define-policy.ts:51
Optional construction-time config validation.
Called once when the factory is invoked (before any requests). Throw a GatewayError to reject invalid config eagerly rather than failing on the first request.
Parameters
Section titled “Parameters”config
Section titled “config”TConfig
Returns
Section titled “Returns”void