Expand description
The exit-transformer node — reshapes gateway-generated responses
(“exits”) with a status-code remap and a body template. Reinterpreted
subset of APISIX’s exit-transformer plugin (response-phase: place after
upstream, before client).
§Which exits it applies to
By default the node acts only on responses whose context carries an
error record (Context.errors non-empty) — a failed upstream, a failed
auth callout, an error-handler-rendered body. A deliberate rejection that
left its node on an outcome port (denied, limited, broken, abort,
redirect, …) carries no error record and is therefore not
transformed unless always: true is set.
So to reshape denials and throttles, set always: true and put the node on
the path the outcome port takes:
nodes:
- id: shape-exits
type: exit-transformer
config:
always: true # required: a denial carries no error record
status_map: { "401": 403 }
body: '{"status": $status, "path": "$uri"}'
edges:
- from: auth.denied
to: shape-exits.in # not straight to client
- from: shape-exits.success
to: client.inWith always: true the node transforms every response reaching it,
clean upstream replies included — so give it its own branch as above
rather than putting it on the main success path.
This is a deliberate reinterpretation, not a faithful port. APISIX’s
plugin registers user-supplied Lua functions that receive
(code, body, headers) and return replacements. Arbitrary scripted
transformation belongs to featherbit’s script node; this node keeps the
declarative core of the idea:
status_mapremaps exit status codes (e.g. hide a 502 as a 503), andbodyrenders a{{namespace.path}}template (plus legacy$varinterpolation, including$status) as the new body,
applied only to responses the gateway itself generated (heuristic:
Context.errors non-empty), or unconditionally with always: true.
Structs§
- Exit
Transformer Plugin - Remaps
Context.response.status_codeviastatus_mapand/or replaces the body with an interpolated{{namespace.path}}(plus legacy$var) template — but only when the response was generated by the gateway (Context.errorsnon-empty), unlessalwaysis set. This plugin never fails at execution time.
Functions§
- parse_
status 🔒 - Validates one status code (map key or value): an integer within 100-599.