-
Notifications
You must be signed in to change notification settings - Fork 2.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Proposal: support advanced matching based on POST form #5399
Labels
Comments
+1, Proposal LGTM. |
+1, useful |
4 tasks
4 tasks
请教下,这个新增特性是否支持content-type=application/json的POST请求中的body过滤? |
not support yet, here: Line 186 in cc43b9f
json is nested and complicated. |
@tzssangglass 那还是只能用serverless解决body字段路由的问题了~ 希望可以支持下。。。 |
can you submit a new issue about support this? |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Proposal
Background
Currently, advanced matching only uses URL query data when matching on request content, and does not support advanced matching with fields in POST form as conditions.
Objectives
Support for POST form as matching conditions by adding new matching key.
Solutions
Determine the added matching key prefix
I think we can add a new
post_arg_
prefix as a POST form data prefix, this is similar to thearg_
used in the query parameter currently provided by openresty.Modify the mt metatable in
ctx.lua
and add a new key processorThe main purpose of the current modification is to handle POST form submissions with
Content-Type x-www-form-urlencoded
.Use
ngx.req.read_body()
and fetch data fromngx.req.get_post_args()
according to read requirements in the metatable to achieve complete on-demand inert loading with the help of the metatable feature. The currently usedlua-resty-expr
can automatically get the target value and compare it with the meta table based on the expression.current
arg_
:apisix/apisix/core/ctx.lua
Lines 167 to 176 in 042ce5c
demo:
Pre-fetching modifications
apisix/core/ctx.lua
: Add new key processort/*
: Add test caseOther
What are your ideas?
The text was updated successfully, but these errors were encountered: