Skip to content

interrupt

const interrupt: (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.

InterruptConfig

Condition predicate, status code, body, and headers.

Policy

A Policy at priority 100 (default — users typically set a custom priority).

// Maintenance mode
interrupt({
condition: (c) => c.req.header("x-maintenance") === "true",
statusCode: 503,
body: { maintenance: true, message: "Back soon" },
headers: { "retry-after": "300" },
});
// Health check short-circuit
interrupt({
condition: (c) => c.req.path === "/healthz",
body: "ok",
});