How to skip the plugins #12147
Replies: 2 comments
-
To stop executing other plugins when the first custom plugin is executed based on a certain parameter, you can use the Here's an example configuration: server {
listen unix:$TEST_NGINX_HTML_DIR/nginx.sock;
content_by_lua_block {
local ext = require("lib.ext-plugin")
ext.go({stop = true})
}
} This setup will stop the execution of subsequent plugins when the To continue talking to Dosu, mention @dosu. Help Dosu learn! Give it feedback: Great Response | Irrelevant Answer | Incorrect Sources | Too Verbose | Hallucination | Bug Report | Other |
Beta Was this translation helpful? Give feedback.
-
Hi @renshunhang
You can do so by using the request context. I suggest you to have a look at this blog post: Down the rabbit hole of an Apache APISIX plugin. ExampleFile local _M = {
version = 0.1,
priority = 200,
name = "plugin1",
}
function _M.rewrite(conf, ctx)
-- do something
ctx.my_custom_var = true
end File local _M = {
version = 0.1,
priority = 100,
name = "plugin2",
}
function _M.rewrite(conf, ctx)
if ctx.my_custom_var then
-- plugin1 executed! Do something more
ctx.my_custom_var = nil
fi
end |
Beta Was this translation helpful? Give feedback.
-
I have developed two custom plugins and configured them in a route. If I want to stop executing the other plugins configured in the route when the first plugin is executed based on the value of a certain parameter, how can I do that?
Beta Was this translation helpful? Give feedback.
All reactions