Baoyuantop commented on code in PR #11629:
URL: https://github.com/apache/apisix/pull/11629#discussion_r2801977054
##########
docs/zh/latest/plugins/opa.md:
##########
@@ -2,11 +2,11 @@
title: opa
keywords:
- Apache APISIX
- - API 网关
- - Plugin
+ - API Gateway
+ - 插件
- Open Policy Agent
- opa
-description: 本篇文档介绍了 Apache APISIX 通过 opa 插件与 Open Policy Agent 对接的相关信息。
+description: 本文档包含有关 Apache APISIX opa 插件的信息。
Review Comment:
These changes are irrelevant to this PR; please minimize these irrelevant
changes.
##########
docs/en/latest/plugins/opa.md:
##########
@@ -78,7 +79,8 @@ The JSON below shows the data sent to the OPA service by
APISIX:
},
"route": {},
"service": {},
- "consumer": {}
+ "consumer": {},
+ "body": {}
Review Comment:
Please confirm the location of the body data. Based on the code, the body is
located below the request level.
##########
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 then
+ return nil, "failed to get request body: " .. err
+ end
+ if original_body == nil then
+ return nil
+ end
+ -- decode to prevent double encoded json objects
+ local body, err = core.json.decode(original_body)
+ if err ~= nil then
Review Comment:
```suggestion
if err then
```
--
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]