Baoyuantop commented on code in PR #11629:
URL: https://github.com/apache/apisix/pull/11629#discussion_r2011221058


##########
apisix/plugins/opa/helper.lua:
##########
@@ -34,9 +34,25 @@ local function build_var(conf, ctx)
     }
 end
 
+local function get_body_for_request()
+    local original_body, err = core.request.get_body()
+    if err ~= nil then

Review Comment:
   ```suggestion
       if err then
   ```



##########
docs/en/latest/plugins/opa.md:
##########
@@ -46,6 +46,7 @@ The `opa` Plugin can be used to integrate with [Open Policy 
Agent (OPA)](https:/
 | with_route        | boolean | False    | false   |               | When set 
to true, sends information about the current Route.                             
                                                                                
                  |
 | with_service      | boolean | False    | false   |               | When set 
to true, sends information about the current Service.                           
                                                                                
                  |
 | with_consumer     | boolean | False    | false   |               | When set 
to true, sends information about the current Consumer. Note that this may send 
sensitive information like the API key. Make sure to turn it on only when you 
are sure it is safe. |
+| with_body         | boolean | False    | false   |               | When set 
to true, sends the request body. |

Review Comment:
   The Data definition section also needs to be supplemented.



##########
apisix/plugins/opa/helper.lua:
##########
@@ -45,8 +61,18 @@ local function build_http_request(conf, ctx)
         headers = core.request.headers(ctx),
         query   = core.request.get_uri_args(ctx),
     }
-end
 
+    if conf.with_body then
+        local body, err = get_body_for_request()
+        if err then
+            core.log.warn(err)

Review Comment:
   core.log.error ?



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

Reply via email to