bzp2010 opened a new issue #5399: URL: https://github.com/apache/apisix/issues/5399
# 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 the `arg_` used in the query parameter currently provided by openresty. ### Modify the mt metatable in `ctx.lua` and add a new key processor The 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 from `ngx.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 used `lua-resty-expr` can automatically get the target value and compare it with the meta table based on the expression. current `arg_`: [https://github.com/apache/apisix/blob/042ce5c1a6a4e040d6d6924f2d86e5534b730134/apisix/core/ctx.lua#L167-L176](https://github.com/apache/apisix/blob/042ce5c1a6a4e040d6d6924f2d86e5534b730134/apisix/core/ctx.lua#L167-L176) demo: ```lua if core_str.has_prefix(key,"post_arg_") then ngx.req.read_body() local args, err = ngx.req.get_post_args() loacl post_arg_key = sub_str(key, 10) val = args[post_arg_key] ``` ## Pre-fetching modifications 1. `apisix/core/ctx.lua`: Add new key processor 2. `t/*`: Add test case 3. Add documents for new function 4. Optional: Add support for its configuration to the Dashboard ## Other What are your ideas? -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
