echo
Replaces or wraps the upstream response body and adds response headers, for testing.
echoPriority 412What it does
echo changes the body and headers of the answer a route gives, for testing. Body replaces the backend's response body with your text, Before body and After body add text in front of it and after it, and Headers adds headers.
The request still reaches the backend, and the client keeps the status it answered with. When no backend answers, the client gets 502 carrying your text in place of the body.
When to use it
- Trying out on a test route what a client sees once the answer's body changes, before you set up response-rewrite on the orders API.
- Marking the answers of a test route with a header, so that testers can tell them apart.
- Wrapping the backend's answer in text before and after it, to see how a client copes with a body it did not expect.
Not for rewriting the answers of a route your clients rely on — see response-rewrite (Rewrites the response status, headers and body), answering with a made-up response and no backend at all — see mocking (Answers requests with a mocked response instead of an upstream) or making a route fail or slow on purpose — see fault-injection (Injects delays or fixed responses for testing).
Set it up
Replace the backend's response body with a fixed text
The request still reaches the backend and its status is kept; only the body and the headers named here change.
Set Body to accepted and fill Headers as in the JSON below.
{
"body": "accepted",
"headers": {
"Content-Type": "text/plain"
}
}
Things to know
- Body — The backend still receives the request and its status stays: with
acceptedas the body, a request is answered200withaccepted. - Body — The gateway's own answers are rewritten too. When the backend refuses the connection, the client gets
502carryingaccepted. - Headers — A header named here is the one the client gets: with
Content-Typeattext/plain, the answer carriesContent-Typewithtext/plain. - Headers — A value is a text or a number. Any other value,
truefor example, is refused when you save. - Headers alone are refused when you save: the plugin needs Body, Before body or After body.
- AdviceKeep echo on a test route of its own, not on a route your clients call.
Settings
The fields as the console shows them, section by section.
bodystringRequired unless Before body or After body is setReplaces the upstream response body with this text.
before_bodystringRequired unless Body or After body is setText added in front of the response body.
after_bodystringRequired unless Before body or Body is setText added after the response body.
headersobjectHeaders added to the response. An object whose keys are any name, each with a string or number as its value.