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
scriptnode.
Configuration
All keys are optional.
| Key | Type | Default | Description |
|---|---|---|---|
status_map | map 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. |
body | string | — | Replacement 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. |
always | bool | false | Apply 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.
- Gate — unless
always: true, the node only acts whencontext.errorsis non-empty (a gateway-generated exit). Otherwise the context passes through unchanged. - Status remap — if the current status is a
status_mapkey, it is replaced. Statuses without a mapping are kept. - Body template — if
bodyis configured, it is interpolated against the context (after the remap, so$statusis the final client-visible code) and replaces the response body; the stalecontent-lengthandcontent-encodingheaders 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.