ext-plugin-post-req
Runs external plugins in the access phase, after the built-in ones.
ext-plugin-post-reqPriority -3000What it does
ext-plugin-post-req hands each request the route takes to an external plugin runner, a program beside the gateway that runs plugins your team writes, in Go, Java or Python for example. It does so in the access phase, after the gateway's built-in plugins of that phase. Runner settings are name and value pairs passed to the runner 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. While the runner does not answer, every request on the route is refused with 503. How G8 handles a request explains phases.
When to use it
- The backend of the orders API needs a header your own code looks up, for example the customer's tier, added once the gateway's plugins have run.
- A check your company maintains as its own plugin, outside the gateway, that should see a request only after the built-in plugins let it through.
- One plugin of your own used on several routes, each route giving it different settings by name.
Not for handing the request to the runner before the other plugins — see ext-plugin-pre-req (Runs external plugins before the request reaches the upstream), a few lines of code on one route, without a runner — see serverless-post-function (Runs Lua functions after the other plugins of a phase) or changing the path, Host or headers the backend receives — see proxy-rewrite (Rewrites the request URI, method, host and headers before proxying).
Set it up
Hand the request to an external runner after the other plugins have run
Needs the runner the gateway's static configuration starts; without it every request answers 503.
Fill Runner settings as in the JSON below.
{
"conf": [
{
"name": "request-enricher",
"value": "{\"lookup\":\"customer\",\"header\":\"X-Customer-Tier\"}"
}
]
}
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 — While the runner does not answer, every request here is refused with 503. With this on, requests go on as if the plugin were absent.
- 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