You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@apisix.apache.org by GitBox <gi...@apache.org> on 2021/11/03 05:52:37 UTC

[GitHub] [apisix] bzp2010 opened a new pull request #5409: feat: support advanced matching based on post form

bzp2010 opened a new pull request #5409:
URL: https://github.com/apache/apisix/pull/5409


   ### What this PR does / why we need it:
   
   Support for POST form as matching conditions in advanced matching.
   
   proposal issue: #5399 
   
   ### Pre-submission checklist:
   
   <!--
   Please follow the requirements:
   1. Use Draft if the PR is not ready to be reviewed
   2. Test is required for the feat/fix PR, unless you have a good reason
   3. Doc is required for the feat PR
   4. Use a new commit to resolve review instead of `push -f`
   5. Use "request review" to notify the reviewer once you have resolved the review
   -->
   
   * [x] Did you explain what problem does this PR solve? Or what new features have been added?
   * [x] Have you added corresponding test cases?
   * [x] Have you modified the corresponding document?
   * [x] Is this PR backward compatible? **If it is not backward compatible, please discuss on the [mailing list](https://github.com/apache/apisix/tree/master#community) first**
   


-- 
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: notifications-unsubscribe@apisix.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [apisix] bzp2010 commented on a change in pull request #5409: feat: support advanced matching based on post form

Posted by GitBox <gi...@apache.org>.
bzp2010 commented on a change in pull request #5409:
URL: https://github.com/apache/apisix/pull/5409#discussion_r744411431



##########
File path: docs/en/latest/router-radixtree.md
##########
@@ -218,6 +218,31 @@ $ curl http://127.0.0.1:9080/apisix/admin/routes/1 -H 'X-API-KEY: edd1c9f034335f
 
 This route will require the request header `host` equal `iresty.com`, request cookie key `_device_id` equal `a66f0cdc4ba2df8c096f74c9110163a9` etc.
 
+### How to filter route by POST form attributes {#post_args}

Review comment:
       OK, I've removed it. 




-- 
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: notifications-unsubscribe@apisix.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [apisix] bzp2010 commented on a change in pull request #5409: feat: support advanced matching based on post form

Posted by GitBox <gi...@apache.org>.
bzp2010 commented on a change in pull request #5409:
URL: https://github.com/apache/apisix/pull/5409#discussion_r744356540



##########
File path: docs/en/latest/router-radixtree.md
##########
@@ -218,6 +218,31 @@ $ curl http://127.0.0.1:9080/apisix/admin/routes/1 -H 'X-API-KEY: edd1c9f034335f
 
 This route will require the request header `host` equal `iresty.com`, request cookie key `_device_id` equal `a66f0cdc4ba2df8c096f74c9110163a9` etc.
 
+### How to filter route by POST form attributes {#post_args}

Review comment:
       If the value of the anchor is not specified, a mismatch will occur between the English document and the Chinese document, is this really not necessary?




-- 
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: notifications-unsubscribe@apisix.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [apisix] spacewander merged pull request #5409: feat: support advanced matching based on post form

Posted by GitBox <gi...@apache.org>.
spacewander merged pull request #5409:
URL: https://github.com/apache/apisix/pull/5409


   


-- 
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: notifications-unsubscribe@apisix.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [apisix] bzp2010 commented on a change in pull request #5409: feat: support advanced matching based on post form

Posted by GitBox <gi...@apache.org>.
bzp2010 commented on a change in pull request #5409:
URL: https://github.com/apache/apisix/pull/5409#discussion_r743516483



##########
File path: t/core/request.t
##########
@@ -378,3 +378,41 @@ nil
 t
 --- no_error_log
 [error]
+
+
+
+=== TEST 11: get_post_args
+--- config
+    location = /hello {
+        real_ip_header X-Real-IP;
+
+        set_real_ip_from 0.0.0.0/0;
+        set_real_ip_from ::/0;
+        set_real_ip_from unix:;
+
+        access_by_lua_block {
+            local core = require("apisix.core")
+            local ngx_ctx = ngx.ctx
+            local api_ctx = ngx_ctx.api_ctx
+            if api_ctx == nil then
+                api_ctx = core.tablepool.fetch("api_ctx", 0, 32)
+                ngx_ctx.api_ctx = api_ctx
+            end
+
+            core.ctx.set_vars_meta(api_ctx)
+        }
+        content_by_lua_block {

Review comment:
       merged

##########
File path: t/core/request.t
##########
@@ -378,3 +378,41 @@ nil
 t
 --- no_error_log
 [error]
+
+
+
+=== TEST 11: get_post_args
+--- config
+    location = /hello {
+        real_ip_header X-Real-IP;
+
+        set_real_ip_from 0.0.0.0/0;
+        set_real_ip_from ::/0;
+        set_real_ip_from unix:;

Review comment:
       removed




-- 
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: notifications-unsubscribe@apisix.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [apisix] spacewander commented on a change in pull request #5409: feat: support advanced matching based on post form

Posted by GitBox <gi...@apache.org>.
spacewander commented on a change in pull request #5409:
URL: https://github.com/apache/apisix/pull/5409#discussion_r743417550



##########
File path: t/core/request.t
##########
@@ -378,3 +378,41 @@ nil
 t
 --- no_error_log
 [error]
+
+
+
+=== TEST 11: get_post_args
+--- config
+    location = /hello {
+        real_ip_header X-Real-IP;
+
+        set_real_ip_from 0.0.0.0/0;
+        set_real_ip_from ::/0;
+        set_real_ip_from unix:;

Review comment:
       Do we need the real_ip stuff?

##########
File path: apisix/core/ctx.lua
##########
@@ -175,6 +175,20 @@ do
                     end
                 end
 
+            elseif core_str.has_prefix(key, "post_arg_") then
+                -- only match default post form
+                if request.header(nil, "Content-Type") == "application/x-www-form-urlencoded" then

Review comment:
       Let's add a new section in https://github.com/apache/apisix/blob/master/docs/en/latest/router-radixtree.md

##########
File path: t/node/vars.t
##########
@@ -299,3 +299,87 @@ GET /hello?k=uri_arg
 hello world
 --- no_error_log
 [error]
+
+
+
+=== TEST 17: set route(only post arg)
+--- config
+    location /t {
+        content_by_lua_block {
+            local t = require("lib.test_admin").test
+            local code, body = t('/apisix/admin/routes/1',
+                ngx.HTTP_PUT,
+                [=[{
+                    "uri": "/hello",
+                    "vars": [["post_arg_k", "==", "post_form"]],
+                    "upstream": {
+                        "nodes": {
+                            "127.0.0.1:1980": 1
+                        },
+                        "type": "roundrobin"
+                    }
+                }]=]
+                )
+
+            if code >= 300 then
+                ngx.status = code
+            end
+            ngx.say(body)
+        }
+    }
+--- request
+GET /t
+--- response_body
+passed
+--- no_error_log
+[error]
+
+
+
+=== TEST 18: /not_found
+--- request
+GET /hello
+--- error_code: 404
+--- response_body
+{"error_msg":"404 Route Not Found"}
+--- no_error_log
+[error]
+
+
+
+=== TEST 19: /not_found

Review comment:
       Should use different names for consequential different tests

##########
File path: t/core/request.t
##########
@@ -378,3 +378,41 @@ nil
 t
 --- no_error_log
 [error]
+
+
+
+=== TEST 11: get_post_args
+--- config
+    location = /hello {
+        real_ip_header X-Real-IP;
+
+        set_real_ip_from 0.0.0.0/0;
+        set_real_ip_from ::/0;
+        set_real_ip_from unix:;
+
+        access_by_lua_block {
+            local core = require("apisix.core")
+            local ngx_ctx = ngx.ctx
+            local api_ctx = ngx_ctx.api_ctx
+            if api_ctx == nil then
+                api_ctx = core.tablepool.fetch("api_ctx", 0, 32)
+                ngx_ctx.api_ctx = api_ctx
+            end
+
+            core.ctx.set_vars_meta(api_ctx)
+        }
+        content_by_lua_block {

Review comment:
       Look like we can put the thing from access_by_lua_block into content_by_lua_block




-- 
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: notifications-unsubscribe@apisix.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [apisix] bzp2010 commented on a change in pull request #5409: feat: support advanced matching based on post form

Posted by GitBox <gi...@apache.org>.
bzp2010 commented on a change in pull request #5409:
URL: https://github.com/apache/apisix/pull/5409#discussion_r743518180



##########
File path: apisix/core/ctx.lua
##########
@@ -175,6 +175,20 @@ do
                     end
                 end
 
+            elseif core_str.has_prefix(key, "post_arg_") then
+                -- only match default post form
+                if request.header(nil, "Content-Type") == "application/x-www-form-urlencoded" then

Review comment:
       @spacewander I've added a brief description, check to see if you need to add a separate paragraph `Howto` for descripte.




-- 
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: notifications-unsubscribe@apisix.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [apisix] bzp2010 commented on a change in pull request #5409: feat: support advanced matching based on post form

Posted by GitBox <gi...@apache.org>.
bzp2010 commented on a change in pull request #5409:
URL: https://github.com/apache/apisix/pull/5409#discussion_r743516350



##########
File path: t/node/vars.t
##########
@@ -299,3 +299,87 @@ GET /hello?k=uri_arg
 hello world
 --- no_error_log
 [error]
+
+
+
+=== TEST 17: set route(only post arg)
+--- config
+    location /t {
+        content_by_lua_block {
+            local t = require("lib.test_admin").test
+            local code, body = t('/apisix/admin/routes/1',
+                ngx.HTTP_PUT,
+                [=[{
+                    "uri": "/hello",
+                    "vars": [["post_arg_k", "==", "post_form"]],
+                    "upstream": {
+                        "nodes": {
+                            "127.0.0.1:1980": 1
+                        },
+                        "type": "roundrobin"
+                    }
+                }]=]
+                )
+
+            if code >= 300 then
+                ngx.status = code
+            end
+            ngx.say(body)
+        }
+    }
+--- request
+GET /t
+--- response_body
+passed
+--- no_error_log
+[error]
+
+
+
+=== TEST 18: /not_found
+--- request
+GET /hello
+--- error_code: 404
+--- response_body
+{"error_msg":"404 Route Not Found"}
+--- no_error_log
+[error]
+
+
+
+=== TEST 19: /not_found

Review comment:
       changed

##########
File path: t/core/request.t
##########
@@ -378,3 +378,41 @@ nil
 t
 --- no_error_log
 [error]
+
+
+
+=== TEST 11: get_post_args
+--- config
+    location = /hello {
+        real_ip_header X-Real-IP;
+
+        set_real_ip_from 0.0.0.0/0;
+        set_real_ip_from ::/0;
+        set_real_ip_from unix:;
+
+        access_by_lua_block {
+            local core = require("apisix.core")
+            local ngx_ctx = ngx.ctx
+            local api_ctx = ngx_ctx.api_ctx
+            if api_ctx == nil then
+                api_ctx = core.tablepool.fetch("api_ctx", 0, 32)
+                ngx_ctx.api_ctx = api_ctx
+            end
+
+            core.ctx.set_vars_meta(api_ctx)
+        }
+        content_by_lua_block {

Review comment:
       merged

##########
File path: t/core/request.t
##########
@@ -378,3 +378,41 @@ nil
 t
 --- no_error_log
 [error]
+
+
+
+=== TEST 11: get_post_args
+--- config
+    location = /hello {
+        real_ip_header X-Real-IP;
+
+        set_real_ip_from 0.0.0.0/0;
+        set_real_ip_from ::/0;
+        set_real_ip_from unix:;

Review comment:
       removed

##########
File path: apisix/core/ctx.lua
##########
@@ -175,6 +175,20 @@ do
                     end
                 end
 
+            elseif core_str.has_prefix(key, "post_arg_") then
+                -- only match default post form
+                if request.header(nil, "Content-Type") == "application/x-www-form-urlencoded" then

Review comment:
       @spacewander I've added a brief description, check to see if you need to add a separate paragraph `Howto` for descripte.




-- 
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: notifications-unsubscribe@apisix.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [apisix] bzp2010 commented on a change in pull request #5409: feat: support advanced matching based on post form

Posted by GitBox <gi...@apache.org>.
bzp2010 commented on a change in pull request #5409:
URL: https://github.com/apache/apisix/pull/5409#discussion_r744356576



##########
File path: docs/en/latest/router-radixtree.md
##########
@@ -216,7 +217,7 @@ $ curl http://127.0.0.1:9080/apisix/admin/routes/1 -H 'X-API-KEY: edd1c9f034335f
 }'
 ```
 
-This route will require the request header `host` equal `iresty.com`, request cookie key `_device_id` equal `a66f0cdc4ba2df8c096f74c9110163a9` etc.
+This route will require the request header `host` equal `iresty.com`, request cookie key `_device_id` equal `a66f0cdc4ba2df8c096f74c9110163a9` etc. And the POST form property match requires you to use `Content-Type: application/x-www-form-urlencoded` for the request to work properly.

Review comment:
       fixed




-- 
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: notifications-unsubscribe@apisix.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [apisix] bzp2010 commented on a change in pull request #5409: feat: support advanced matching based on post form

Posted by GitBox <gi...@apache.org>.
bzp2010 commented on a change in pull request #5409:
URL: https://github.com/apache/apisix/pull/5409#discussion_r743516350



##########
File path: t/node/vars.t
##########
@@ -299,3 +299,87 @@ GET /hello?k=uri_arg
 hello world
 --- no_error_log
 [error]
+
+
+
+=== TEST 17: set route(only post arg)
+--- config
+    location /t {
+        content_by_lua_block {
+            local t = require("lib.test_admin").test
+            local code, body = t('/apisix/admin/routes/1',
+                ngx.HTTP_PUT,
+                [=[{
+                    "uri": "/hello",
+                    "vars": [["post_arg_k", "==", "post_form"]],
+                    "upstream": {
+                        "nodes": {
+                            "127.0.0.1:1980": 1
+                        },
+                        "type": "roundrobin"
+                    }
+                }]=]
+                )
+
+            if code >= 300 then
+                ngx.status = code
+            end
+            ngx.say(body)
+        }
+    }
+--- request
+GET /t
+--- response_body
+passed
+--- no_error_log
+[error]
+
+
+
+=== TEST 18: /not_found
+--- request
+GET /hello
+--- error_code: 404
+--- response_body
+{"error_msg":"404 Route Not Found"}
+--- no_error_log
+[error]
+
+
+
+=== TEST 19: /not_found

Review comment:
       changed

##########
File path: t/core/request.t
##########
@@ -378,3 +378,41 @@ nil
 t
 --- no_error_log
 [error]
+
+
+
+=== TEST 11: get_post_args
+--- config
+    location = /hello {
+        real_ip_header X-Real-IP;
+
+        set_real_ip_from 0.0.0.0/0;
+        set_real_ip_from ::/0;
+        set_real_ip_from unix:;
+
+        access_by_lua_block {
+            local core = require("apisix.core")
+            local ngx_ctx = ngx.ctx
+            local api_ctx = ngx_ctx.api_ctx
+            if api_ctx == nil then
+                api_ctx = core.tablepool.fetch("api_ctx", 0, 32)
+                ngx_ctx.api_ctx = api_ctx
+            end
+
+            core.ctx.set_vars_meta(api_ctx)
+        }
+        content_by_lua_block {

Review comment:
       merged

##########
File path: t/core/request.t
##########
@@ -378,3 +378,41 @@ nil
 t
 --- no_error_log
 [error]
+
+
+
+=== TEST 11: get_post_args
+--- config
+    location = /hello {
+        real_ip_header X-Real-IP;
+
+        set_real_ip_from 0.0.0.0/0;
+        set_real_ip_from ::/0;
+        set_real_ip_from unix:;

Review comment:
       removed

##########
File path: apisix/core/ctx.lua
##########
@@ -175,6 +175,20 @@ do
                     end
                 end
 
+            elseif core_str.has_prefix(key, "post_arg_") then
+                -- only match default post form
+                if request.header(nil, "Content-Type") == "application/x-www-form-urlencoded" then

Review comment:
       @spacewander I've added a brief description, check to see if you need to add a separate paragraph `Howto` for descripte.




-- 
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: notifications-unsubscribe@apisix.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [apisix] spacewander commented on a change in pull request #5409: feat: support advanced matching based on post form

Posted by GitBox <gi...@apache.org>.
spacewander commented on a change in pull request #5409:
URL: https://github.com/apache/apisix/pull/5409#discussion_r744259005



##########
File path: docs/en/latest/router-radixtree.md
##########
@@ -216,7 +217,7 @@ $ curl http://127.0.0.1:9080/apisix/admin/routes/1 -H 'X-API-KEY: edd1c9f034335f
 }'
 ```
 
-This route will require the request header `host` equal `iresty.com`, request cookie key `_device_id` equal `a66f0cdc4ba2df8c096f74c9110163a9` etc.
+This route will require the request header `host` equal `iresty.com`, request cookie key `_device_id` equal `a66f0cdc4ba2df8c096f74c9110163a9` etc. And the POST form property match requires you to use `Content-Type: application/x-www-form-urlencoded` for the request to work properly.

Review comment:
       I think the post form property worths an individual section like the `graphql_` one.




-- 
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: notifications-unsubscribe@apisix.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [apisix] spacewander commented on a change in pull request #5409: feat: support advanced matching based on post form

Posted by GitBox <gi...@apache.org>.
spacewander commented on a change in pull request #5409:
URL: https://github.com/apache/apisix/pull/5409#discussion_r744346369



##########
File path: docs/en/latest/router-radixtree.md
##########
@@ -218,6 +218,31 @@ $ curl http://127.0.0.1:9080/apisix/admin/routes/1 -H 'X-API-KEY: edd1c9f034335f
 
 This route will require the request header `host` equal `iresty.com`, request cookie key `_device_id` equal `a66f0cdc4ba2df8c096f74c9110163a9` etc.
 
+### How to filter route by POST form attributes {#post_args}

Review comment:
       We don't need `{#post_args}` now. The anchor is not ambiguous.




-- 
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: notifications-unsubscribe@apisix.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [apisix] bzp2010 commented on a change in pull request #5409: feat: support advanced matching based on post form

Posted by GitBox <gi...@apache.org>.
bzp2010 commented on a change in pull request #5409:
URL: https://github.com/apache/apisix/pull/5409#discussion_r743516350



##########
File path: t/node/vars.t
##########
@@ -299,3 +299,87 @@ GET /hello?k=uri_arg
 hello world
 --- no_error_log
 [error]
+
+
+
+=== TEST 17: set route(only post arg)
+--- config
+    location /t {
+        content_by_lua_block {
+            local t = require("lib.test_admin").test
+            local code, body = t('/apisix/admin/routes/1',
+                ngx.HTTP_PUT,
+                [=[{
+                    "uri": "/hello",
+                    "vars": [["post_arg_k", "==", "post_form"]],
+                    "upstream": {
+                        "nodes": {
+                            "127.0.0.1:1980": 1
+                        },
+                        "type": "roundrobin"
+                    }
+                }]=]
+                )
+
+            if code >= 300 then
+                ngx.status = code
+            end
+            ngx.say(body)
+        }
+    }
+--- request
+GET /t
+--- response_body
+passed
+--- no_error_log
+[error]
+
+
+
+=== TEST 18: /not_found
+--- request
+GET /hello
+--- error_code: 404
+--- response_body
+{"error_msg":"404 Route Not Found"}
+--- no_error_log
+[error]
+
+
+
+=== TEST 19: /not_found

Review comment:
       changed




-- 
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: notifications-unsubscribe@apisix.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [apisix] spacewander commented on a change in pull request #5409: feat: support advanced matching based on post form

Posted by GitBox <gi...@apache.org>.
spacewander commented on a change in pull request #5409:
URL: https://github.com/apache/apisix/pull/5409#discussion_r743417550



##########
File path: t/core/request.t
##########
@@ -378,3 +378,41 @@ nil
 t
 --- no_error_log
 [error]
+
+
+
+=== TEST 11: get_post_args
+--- config
+    location = /hello {
+        real_ip_header X-Real-IP;
+
+        set_real_ip_from 0.0.0.0/0;
+        set_real_ip_from ::/0;
+        set_real_ip_from unix:;

Review comment:
       Do we need the real_ip stuff?

##########
File path: apisix/core/ctx.lua
##########
@@ -175,6 +175,20 @@ do
                     end
                 end
 
+            elseif core_str.has_prefix(key, "post_arg_") then
+                -- only match default post form
+                if request.header(nil, "Content-Type") == "application/x-www-form-urlencoded" then

Review comment:
       Let's add a new section in https://github.com/apache/apisix/blob/master/docs/en/latest/router-radixtree.md

##########
File path: t/node/vars.t
##########
@@ -299,3 +299,87 @@ GET /hello?k=uri_arg
 hello world
 --- no_error_log
 [error]
+
+
+
+=== TEST 17: set route(only post arg)
+--- config
+    location /t {
+        content_by_lua_block {
+            local t = require("lib.test_admin").test
+            local code, body = t('/apisix/admin/routes/1',
+                ngx.HTTP_PUT,
+                [=[{
+                    "uri": "/hello",
+                    "vars": [["post_arg_k", "==", "post_form"]],
+                    "upstream": {
+                        "nodes": {
+                            "127.0.0.1:1980": 1
+                        },
+                        "type": "roundrobin"
+                    }
+                }]=]
+                )
+
+            if code >= 300 then
+                ngx.status = code
+            end
+            ngx.say(body)
+        }
+    }
+--- request
+GET /t
+--- response_body
+passed
+--- no_error_log
+[error]
+
+
+
+=== TEST 18: /not_found
+--- request
+GET /hello
+--- error_code: 404
+--- response_body
+{"error_msg":"404 Route Not Found"}
+--- no_error_log
+[error]
+
+
+
+=== TEST 19: /not_found

Review comment:
       Should use different names for consequential different tests

##########
File path: t/core/request.t
##########
@@ -378,3 +378,41 @@ nil
 t
 --- no_error_log
 [error]
+
+
+
+=== TEST 11: get_post_args
+--- config
+    location = /hello {
+        real_ip_header X-Real-IP;
+
+        set_real_ip_from 0.0.0.0/0;
+        set_real_ip_from ::/0;
+        set_real_ip_from unix:;
+
+        access_by_lua_block {
+            local core = require("apisix.core")
+            local ngx_ctx = ngx.ctx
+            local api_ctx = ngx_ctx.api_ctx
+            if api_ctx == nil then
+                api_ctx = core.tablepool.fetch("api_ctx", 0, 32)
+                ngx_ctx.api_ctx = api_ctx
+            end
+
+            core.ctx.set_vars_meta(api_ctx)
+        }
+        content_by_lua_block {

Review comment:
       Look like we can put the thing from access_by_lua_block into content_by_lua_block

##########
File path: t/core/request.t
##########
@@ -378,3 +378,41 @@ nil
 t
 --- no_error_log
 [error]
+
+
+
+=== TEST 11: get_post_args
+--- config
+    location = /hello {
+        real_ip_header X-Real-IP;
+
+        set_real_ip_from 0.0.0.0/0;
+        set_real_ip_from ::/0;
+        set_real_ip_from unix:;

Review comment:
       Do we need the real_ip stuff?

##########
File path: apisix/core/ctx.lua
##########
@@ -175,6 +175,20 @@ do
                     end
                 end
 
+            elseif core_str.has_prefix(key, "post_arg_") then
+                -- only match default post form
+                if request.header(nil, "Content-Type") == "application/x-www-form-urlencoded" then

Review comment:
       Let's add a new section in https://github.com/apache/apisix/blob/master/docs/en/latest/router-radixtree.md

##########
File path: t/node/vars.t
##########
@@ -299,3 +299,87 @@ GET /hello?k=uri_arg
 hello world
 --- no_error_log
 [error]
+
+
+
+=== TEST 17: set route(only post arg)
+--- config
+    location /t {
+        content_by_lua_block {
+            local t = require("lib.test_admin").test
+            local code, body = t('/apisix/admin/routes/1',
+                ngx.HTTP_PUT,
+                [=[{
+                    "uri": "/hello",
+                    "vars": [["post_arg_k", "==", "post_form"]],
+                    "upstream": {
+                        "nodes": {
+                            "127.0.0.1:1980": 1
+                        },
+                        "type": "roundrobin"
+                    }
+                }]=]
+                )
+
+            if code >= 300 then
+                ngx.status = code
+            end
+            ngx.say(body)
+        }
+    }
+--- request
+GET /t
+--- response_body
+passed
+--- no_error_log
+[error]
+
+
+
+=== TEST 18: /not_found
+--- request
+GET /hello
+--- error_code: 404
+--- response_body
+{"error_msg":"404 Route Not Found"}
+--- no_error_log
+[error]
+
+
+
+=== TEST 19: /not_found

Review comment:
       Should use different names for consequential different tests

##########
File path: t/core/request.t
##########
@@ -378,3 +378,41 @@ nil
 t
 --- no_error_log
 [error]
+
+
+
+=== TEST 11: get_post_args
+--- config
+    location = /hello {
+        real_ip_header X-Real-IP;
+
+        set_real_ip_from 0.0.0.0/0;
+        set_real_ip_from ::/0;
+        set_real_ip_from unix:;
+
+        access_by_lua_block {
+            local core = require("apisix.core")
+            local ngx_ctx = ngx.ctx
+            local api_ctx = ngx_ctx.api_ctx
+            if api_ctx == nil then
+                api_ctx = core.tablepool.fetch("api_ctx", 0, 32)
+                ngx_ctx.api_ctx = api_ctx
+            end
+
+            core.ctx.set_vars_meta(api_ctx)
+        }
+        content_by_lua_block {

Review comment:
       Look like we can put the thing from access_by_lua_block into content_by_lua_block




-- 
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: notifications-unsubscribe@apisix.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [apisix] bzp2010 commented on a change in pull request #5409: feat: support advanced matching based on post form

Posted by GitBox <gi...@apache.org>.
bzp2010 commented on a change in pull request #5409:
URL: https://github.com/apache/apisix/pull/5409#discussion_r744263417



##########
File path: docs/en/latest/router-radixtree.md
##########
@@ -216,7 +217,7 @@ $ curl http://127.0.0.1:9080/apisix/admin/routes/1 -H 'X-API-KEY: edd1c9f034335f
 }'
 ```
 
-This route will require the request header `host` equal `iresty.com`, request cookie key `_device_id` equal `a66f0cdc4ba2df8c096f74c9110163a9` etc.
+This route will require the request header `host` equal `iresty.com`, request cookie key `_device_id` equal `a66f0cdc4ba2df8c096f74c9110163a9` etc. And the POST form property match requires you to use `Content-Type: application/x-www-form-urlencoded` for the request to work properly.

Review comment:
       I will modify it.




-- 
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: notifications-unsubscribe@apisix.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [apisix] spacewander commented on a change in pull request #5409: feat: support advanced matching based on post form

Posted by GitBox <gi...@apache.org>.
spacewander commented on a change in pull request #5409:
URL: https://github.com/apache/apisix/pull/5409#discussion_r744373204



##########
File path: docs/en/latest/router-radixtree.md
##########
@@ -218,6 +218,31 @@ $ curl http://127.0.0.1:9080/apisix/admin/routes/1 -H 'X-API-KEY: edd1c9f034335f
 
 This route will require the request header `host` equal `iresty.com`, request cookie key `_device_id` equal `a66f0cdc4ba2df8c096f74c9110163a9` etc.
 
+### How to filter route by POST form attributes {#post_args}

Review comment:
       Just using the name displayed in the title is enough. It's quite strange to use a custom anchor (and hard to remember too).




-- 
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: notifications-unsubscribe@apisix.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org