Expand description
The body-transformer node — rewrites the request and/or response body
from a template.
§Deviation from APISIX (read this first)
APISIX’s body-transformer renders full lua-resty-template templates
(arbitrary Lua expressions, loops, helpers) over bodies decoded from
xml, json, encoded, args, plain, or multipart input.
featherbit implements a deliberate subset:
-
input_formatsupportsjsononly (other formats are rejected at config load; omitting it defaults tojson). -
Templates are plain strings with two placeholder forms:
{{body.x.y}}— a dotted path resolved from the parsed JSON body (numeric segments index arrays;{{body}}is the whole document). Strings are inserted raw (unquoted), numbers/bools verbatim, missing values andnullas the empty string, and objects/arrays as compact JSON.{{$var}}— a context variable viacrate::vars::resolve($uri,$http_x_id,$arg_page, …).
Text outside
{{ }}additionally passes throughcrate::vars::interpolate, so bare$varreferences work there too. -
template_is_base64is not supported (templates are stored literally in YAML) and is rejected at config load.
Structs§
- Body
Transformer Plugin - Rewrites
context.request.bodyand/orcontext.response.bodyby rendering a template against the parsed JSON body and context variables.
Functions§
- json_
path 🔒 - Resolves a dotted path (
x.y.0) inside a JSON value; an empty path returns the value itself. - json_
to_ 🔒template_ string - Stringifies a resolved JSON value for template insertion: strings raw,
scalars verbatim,
nullempty, containers as compact JSON. - parse_
body 🔒 - Parses a body as JSON; empty bodies become
nullso templates still render (with empty{{body...}}placeholders). - parse_
transform 🔒 - Validates one
request/responsetransform object and returns its template string. - render 🔒
- Renders a template:
{{body.path}}from the parsed body,{{$var}}viacrate::vars::resolve, and$varinterpolation on the literal text between placeholders. Unknown placeholders resolve to the empty string; values substituted from the body are not re-interpolated.