ext-plugin-pre-req
Runs external plugins before the request reaches the upstream.
ext-plugin-pre-reqPriority 12000What it does
ext-plugin-pre-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 before the request reaches the backend. Runner settings are name and value pairs passed to the runner as they are, and their meaning is up to the runner.
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.
When to use it
- Every request to the orders API must be signed by code your team already keeps in Java or Python, before it reaches the backend.
- A check your company maintains as its own plugin, outside the gateway, that requests must pass on some routes.
- One plugin of your own used on several routes, each route giving it different settings by name.
Not for a few lines of code on one route, without a runner — see serverless-pre-function (Runs Lua functions before 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 before any other plugin sees it
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-signer",
"value": "{\"algorithm\":\"hmac-sha256\",\"header\":\"X-Signature\"}"
}
]
}
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