interrupt
constinterrupt: (config?) =>Policy
Defined in: src/policies/traffic/interrupt.ts:49
Conditionally short-circuit the pipeline and return a static response.
Evaluates a predicate against the incoming request context. When the
condition returns true, the pipeline is interrupted — a response is
returned immediately and next() is never called (upstream is skipped).
When the condition returns false, the pipeline continues normally.
Parameters
Section titled “Parameters”config?
Section titled “config?”Condition predicate, status code, body, and headers.
Returns
Section titled “Returns”A Policy at priority 100 (default — users typically set a custom priority).
Example
Section titled “Example”// Maintenance modeinterrupt({ condition: (c) => c.req.header("x-maintenance") === "true", statusCode: 503, body: { maintenance: true, message: "Back soon" }, headers: { "retry-after": "300" },});
// Health check short-circuitinterrupt({ condition: (c) => c.req.path === "/healthz", body: "ok",});