ext-plugin-post-resp
Runs external plugins on the response before it returns.
ext-plugin-post-respPriority -4000What it does
ext-plugin-post-resp hands the backend's answer on a route to an external plugin runner before the answer goes back to the client. The runner is a program beside the gateway that runs plugins your team writes, in Go, Java or Python for example. Runner settings are name and value pairs passed to it as they are.
The form does not name the runner. It is the one the gateway's static configuration starts, so the plugin works only on gateway nodes where that runner runs. The backend is called first, so while the runner does not answer, the client is sent 503 carrying the backend's body.
When to use it
- Answers of the orders API must lose some fields, a card number for example, by code your team keeps in Java or Python.
- A check of the backend's answer your company maintains as its own plugin, outside the gateway.
- One plugin of your own used on several routes, each route giving it different settings by name.
Not for changing the status, headers or body of the answer without a runner — see response-rewrite (Rewrites the response status, headers and body), a few lines of code on the answer, without a runner — see serverless-post-function (Runs Lua functions after the other plugins of a phase) or handing the request to the runner before it reaches the backend — see ext-plugin-pre-req (Runs external plugins before the request reaches the upstream).
Set it up
Hand the response to an external runner before it goes back to the client
Needs the runner the gateway's static configuration starts; without it every request answers 503, so a response never goes out unredacted.
Fill Runner settings as in the JSON below.
{
"conf": [
{
"name": "response-redactor",
"value": "{\"fields\":[\"ssn\",\"card_number\"]}"
}
]
}
Things to know
- Runner settings — The runner is the one the gateway's static configuration starts, and no field on this form names it.
- Runner settings — A setting without a value is refused when you save.
- Runner settings — A setting with an empty name is refused when you save.
- Allow degradation — The upstream is asked before the runner is, so while the runner does not answer the client is sent 503 carrying the body the upstream answered with.
- AdviceBefore you add the plugin to a route your clients call, ask whoever runs the gateway nodes whether the runner is started there.
Settings
The fields as the console shows them, section by section.
confarray of objectsName and value pairs passed as they are to your external plugin runner, such as x = y. Their meaning is up to the runner. The runner is the one the gateway's static configuration starts.
conf[].namestringRequiredconf[].valuestringRequiredallow_degradationbooleandefault false