Skip to main content

Module response_rewrite

Module response_rewrite 

Source
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 options only supports "i" (case-insensitive); APISIX’s PCRE flags j/o are 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 cleared content-length/content-encoding at that point, which garbles the response — we deliberately do not mirror that quirk).

Structs§

BodyFilter 🔒
One compiled body filter: a regex substitution applied once or globally.
ResponseRewritePlugin
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 $var interpolation in header values. An optional vars expression 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 validators last-modified and etag).

Functions§

clear_body_derived_headers 🔒
header_value_to_string 🔒
Stringifies a scalar header value (string or number, matching the APISIX schema); returns None for other shapes.
parse_add_entry 🔒
Splits an add entry of the form "Name: value" into (name, value).
parse_filter 🔒
Parses one filters entry into a compiled BodyFilter.
parse_headers 🔒
Parses the headers config key. Two accepted shapes: