You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@apisix.apache.org by GitBox <gi...@apache.org> on 2021/12/29 02:02:31 UTC

[GitHub] [apisix] leslie-tsang commented on a change in pull request #5941: feat: support registering custom variable

leslie-tsang commented on a change in pull request #5941:
URL: https://github.com/apache/apisix/pull/5941#discussion_r776125463



##########
File path: apisix/core/ctx.lua
##########
@@ -215,11 +215,18 @@ do
                 key = sub_str(key, 9)
                 val = get_parsed_graphql()[key]
 
-            elseif apisix_var_names[key] then
-                val = ngx.ctx.api_ctx and ngx.ctx.api_ctx[key]
-
             else
-                val = get_var(key, t._request)
+                local getter = apisix_var_names[key]
+                if getter then
+                    if getter == true then
+                        val = ngx.ctx.api_ctx and ngx.ctx.api_ctx[key]
+                    else
+                        val = getter(ngx.ctx.api_ctx)

Review comment:
       Maybe we should add a comment here, to notify developer where the `getter` from ?




-- 
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: notifications-unsubscribe@apisix.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org