membphis commented on a change in pull request #2139:
URL: https://github.com/apache/apisix/pull/2139#discussion_r480941998



##########
File path: apisix/plugins/grpc-transcode/util.lua
##########
@@ -47,24 +48,37 @@ function _M.find_method(protos, service, method)
 end
 
 
-local function get_from_request(name, kind)
-    local request_table
-    if ngx.req.get_method() == "POST" then
-        if string.find(ngx.req.get_headers()["Content-Type"] or "",
-                       "application/json", 1, true) then
-            request_table = json.decode(ngx.req.get_body_data())
-        else
-            request_table = ngx.req.get_post_args()
+local function get_request_table()
+    local method = ngx.req.get_method()
+    local content_type = ngx.req.get_headers()["Content-Type"] or ""
+    if string.find(content_type, "application/json", 1, true) and
+        (method == "POST" or method == "PUT" or method == "PATCH")
+    then
+        local req_body, _ = core.request.get_body()
+        if req_body then
+            local data, _ = json.decode(req_body)
+            if data then
+                return data
+            end
         end
-    else
-        request_table = ngx.req.get_uri_args()
     end
 
-    local prefix = kind:sub(1, 3)
-    if prefix == "str" then
-        return request_table[name] or nil
+    if method == "POST" then
+        local post_args = ngx.req.get_post_args()
+        return post_args
+    end
+
+    local args = ngx.req.get_uri_args()

Review comment:
       call `return` directly




----------------------------------------------------------------
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.

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


Reply via email to