Skip to main content

exit-transformer

exit-transformer

Reshapes gateway-generated responses ("exits": auth rejections, rate-limit denials, upstream failures, ...) with a status-code remap and a $var body template. It is a response-phase node — place it after upstream, before client.

Declarative by design. This node covers the declarative core of exit transformation — a status remap plus a body template — applied to gateway-generated exits. In featherbit, arbitrary scripted transformation belongs to the script node.

Configuration

All keys are optional.

KeyTypeDefaultDescription
status_mapmap of status → status{}When the response status matches a key, it is replaced by the value (e.g. "502": 503 hides a bad gateway as service-unavailable). Keys are strings (YAML map keys), values integers; both must be within 100-599.
bodystringReplacement body template with $var / ${var} interpolation: $status (the status after remapping), $uri, $host, $http_<name>, $msg_<key>, and every other context variable. Unknown variables resolve to the empty string.
alwaysboolfalseApply to every response. When false, only responses generated by the gateway itself — heuristic: context.errors is non-empty — are transformed; clean upstream responses pass through untouched.
type: exit-transformer
config:
status_map:
"401": 403
"502": 503
body: '{"status": $status, "path": "$uri"}'

Malformed shapes fail at config load: a non-map status_map, non-numeric or out-of-range statuses, or a non-string body.

Behavior

This plugin never fails at execution time — it always exits through the success port.

  1. Gate — unless always: true, the node only acts when context.errors is non-empty (a gateway-generated exit). Otherwise the context passes through unchanged.
  2. Status remap — if the current status is a status_map key, it is replaced. Statuses without a mapping are kept.
  3. Body template — if body is configured, it is interpolated against the context (after the remap, so $status is the final client-visible code) and replaces the response body; the stale content-length and content-encoding headers are removed (the server layer recomputes the length).

The node does not modify response headers beyond the body-mutation convention — combine with response-rewrite or proxy-rewrite (response phase) for header changes, or use a script node for fully dynamic transformations.

The plugin reads context.errors but never writes it, and does not touch context.message.