Firstsawyou commented on a change in pull request #4109:
URL: https://github.com/apache/apisix/pull/4109#discussion_r618245171



##########
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:
       Got it, updated.




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


Reply via email to