Expand description
The response-rewrite node — rewrites the status code, body, and headers
of the response before it reaches the client. Port of APISIX’s
response-rewrite plugin (response-phase: place after upstream, before
client).
Since featherbit responses are fully buffered in Context.response,
APISIX’s header_filter + body_filter phases collapse into a single
execute().
Deviations from APISIX:
- filter
optionsonly supports"i"(case-insensitive); APISIX’s PCRE flagsj/oare JIT/compile-cache hints with no meaning here and are rejected at config load. - when filters skip because of an unsupported/undecodable
content-encoding, the response headers are left untouched (APISIX has already clearedcontent-length/content-encodingat that point, which garbles the response — we deliberately do not mirror that quirk).
Structs§
- Body
Filter 🔒 - One compiled body filter: a regex substitution applied once or globally.
- Response
Rewrite Plugin - Rewrites
Context.response: optionally forces a status code, replaces the body (with optional base64-decoded config content), applies regex filters to the body, and adds/sets/removes headers with$varinterpolation in header values. An optionalvarsexpression gates the whole node — when present and false the node is a pure passthrough. This plugin never fails at execution time.
Constants§
- BODY_
DERIVED_ 🔒HEADERS - Headers the server layer derives from the final body; stale copies from
the upstream must be dropped whenever the body is replaced. Mirrors
APISIX’s
core.response.clear_header_as_body_modified(which also drops the cache validatorslast-modifiedandetag).
Functions§
- clear_
body_ 🔒derived_ headers - header_
value_ 🔒to_ string - Stringifies a scalar header value (string or number, matching the APISIX
schema); returns
Nonefor other shapes. - parse_
add_ 🔒entry - Splits an
addentry of the form"Name: value"into(name, value). - parse_
filter 🔒 - Parses one
filtersentry into a compiledBodyFilter. - parse_
headers 🔒 - Parses the
headersconfig key. Two accepted shapes: