echo
Rewrites the response: body replaces the upstream body, before_body / after_body are concatenated around it, and headers are set on the response. It is a response-phase node — place it after upstream (between upstream and client) so it sees the upstream response. It is intended as a demo/debugging utility.
Configuration
At least one of body / before_body / after_body is required.
| Key | Type | Default | Description |
|---|---|---|---|
body | string | — | Replaces the upstream response body. |
before_body | string | — | Prepended to the body (after any body replacement). |
after_body | string | — | Appended to the body. |
headers | map or array | {} | Response headers to set. Accepts the map form {name: value} and the array form [{name, value}] (the shape the UI editor saves; blank-name rows are skipped). Values must be scalars (strings, numbers, bools — stringified); names are lowercased. Existing values for the same header are replaced, not appended (like ngx.header). |
type: echo
config:
before_body: "before the body modification "
after_body: " after the body modification"
headers:
x-served-by: featherbit
Malformed shapes are rejected at config load: non-string body keys, a non-map headers, or non-scalar header values all fail with a descriptive error.
Behavior
This plugin never fails at execution time — it always exits through the success port, and the error port is never taken.
On each response, in order:
- With
body, the upstream body is discarded and replaced. Without it, the upstream body is kept — and if it is compressed (content-encoding: gzip,deflate, orbr), it is decoded first sobefore_body/after_bodyconcatenate onto text rather than onto a compressed stream. An unsupported encoding or corrupt stream falls back to the raw bytes. before_bodyandafter_bodyare concatenated around the result.- Per the body-mutation convention,
content-lengthis removed (the server recomputes it from the final body) andcontent-encodingis removed (the body is left decoded). headersare set oncontext.response.headers, replacing any existing values.