spacewander commented on a change in pull request #4109:
URL: https://github.com/apache/apisix/pull/4109#discussion_r618229768
##########
File path: t/core/ctx2.t
##########
@@ -87,3 +87,58 @@ GET /xxx
--- error_log
pre uri: /hello
post uri: /server_port
+
+
+
+=== TEST 3: get balancer_ip and balancer_port through ctx.var
+--- config
+ location /t {
+ content_by_lua_block {
+ local t = require("lib.test_admin").test
+ local code, body = t('/apisix/admin/routes/1',
+ ngx.HTTP_PUT,
+ [[{
+ "uri": "/hello",
+ "plugins": {
+ "serverless-post-function": {
+ "phase": "log",
+ "functions" : ["return function(conf, ctx)
+ ngx.log(ngx.WARN, 'balancer_ip: ',
ctx.var.balancer_ip);
+ ngx.log(ngx.WARN, 'balancer_port: ',
ctx.var.balancer_port);
+ end"]
+ }
+ },
+ "upstream": {
+ "nodes": {
+ "127.0.0.1:1980": 1
+ },
+ "type": "roundrobin"
+ }
+ }]]
+ )
+
+ if code >= 300 then
+ ngx.status = code
+ end
+ ngx.say(body)
+ }
+ }
+--- request
Review comment:
We don't need that stuff. They are already set in
https://github.com/Firstsawyou/apisix/blob/a78bd10f4f1efb3547cae880d7cdea7d7ffb08e1/t/core/ctx2.t#L23
--
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:
[email protected]