bzp2010 commented on code in PR #11289:
URL: https://github.com/apache/apisix/pull/11289#discussion_r1704963383
##########
apisix/core/ctx.lua:
##########
@@ -274,6 +276,19 @@ do
end
end
+ elseif core_str.has_prefix(key, "json_body_arg_") then
+ -- only match json type request body
+ local content_type = request.header(nil, "Content-Type")
+ if content_type ~= nil and core_str.has_prefix(content_type,
+ "application/json") then
+ local arg_key = sub_str(key, 15)
+ local raw_request_body = request.get_body()
+ local body = cjson.decode(raw_request_body)
Review Comment:
```suggestion
local body, err = core.json.decode(raw_request_body)
```
##########
apisix/core/ctx.lua:
##########
@@ -274,6 +276,19 @@ do
end
end
+ elseif core_str.has_prefix(key, "json_body_arg_") then
+ -- only match json type request body
+ local content_type = request.header(nil, "Content-Type")
+ if content_type ~= nil and core_str.has_prefix(content_type,
+ "application/json") then
+ local arg_key = sub_str(key, 15)
+ local raw_request_body = request.get_body()
+ local body = cjson.decode(raw_request_body)
+ if body then
+ val = utils.get_nested_json_value(body, arg_key)
Review Comment:
Can we use jsonpath?
--
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]