tzssangglass commented on code in PR #8205:
URL: https://github.com/apache/apisix/pull/8205#discussion_r1016634339
##########
t/plugin/google-cloud-logging/config.json:
##########
@@ -5,5 +5,5 @@
"scopes": [
"https://apisix.apache.org/logs:admin"
],
- "entries_uri": "http://127.0.0.1:1980/google/logging/entries"
+ "entries_uri": "http://127.0.0.1:12001/google/logging/test1"
Review Comment:
```suggestion
"entries_uri": "http://127.0.0.1:12001/google/logging/entries"
```
##########
t/plugin/google-cloud-logging.t:
##########
@@ -31,6 +31,61 @@ add_block_preprocessor(sub {
if (!defined $block->request) {
$block->set_value("request", "GET /t");
}
+ my $http_config = $block->http_config // <<_EOC_;
+server {
+ listen 12001;
+
+ location /google-cloud-logging/test {
+ content_by_lua_block {
+ ngx.req.read_body()
+ local data = ngx.req.get_body_data()
+ ngx.log(ngx.WARN, "google cloud logging request body: ", data)
+ ngx.log(ngx.ERR, data)
+ ngx.say('test-http-logger-response')
+ ngx.log(ngx.WARN, "loggingBody:", data)
+ }
+ }
+
+
+ location /google/logging/entries {
+ content_by_lua_block {
+ ngx.req.read_body()
+ local body = ngx.req.get_body_data()
+
+ local data, err = require("cjson").decode(body)
+ if err then
+ ngx.log(ngx.WARN, "loggingBody", body)
+ end
+
+ ngx.log(ngx.WARN, "loggingBody", body)
+ ngx.say("ok")
+ ngx.print(body)
+ }
+ }
+
+ location /google/logging/test1 {
+ content_by_lua_block {
+ ngx.req.read_body()
+ local json_decode = require("toolkit.json").decode
+ local json_encode = require("toolkit.json").encode
+ local data = ngx.req.get_body_data()
+ local decoded_data = json_decode(data)
+
+ ngx.log(ngx.WARN,"gcp logs body entries: ",
json_encode(decoded_data["entries"][1]["jsonPayload"]))
+ ngx.say("ok")
+ }
+ }
Review Comment:
```suggestion
location /google-cloud-logging/test {
content_by_lua_block {
ngx.req.read_body()
local data = ngx.req.get_body_data()
ngx.log(ngx.WARN, "google cloud logging request body: ",
data)
ngx.log(ngx.ERR, data)
ngx.say('test-http-logger-response')
ngx.log(ngx.WARN, "loggingBody:", data)
}
}
location /google/logging/entries {
content_by_lua_block {
ngx.req.read_body()
local json_decode = require("toolkit.json").decode
local json_encode = require("toolkit.json").encode
local data = ngx.req.get_body_data()
local decoded_data = json_decode(data)
ngx.log(ngx.WARN,"gcp logs body entries: ",
json_encode(decoded_data["entries"][1]["jsonPayload"]))
ngx.say("ok")
}
}
```
would this work around with ` "entries_uri":
"http://127.0.0.1:12001/google/logging/entries"` in `config.json`
--
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]