zlhgo commented on issue #6184:
URL: https://github.com/apache/apisix/issues/6184#issuecomment-1032213986


   @tzssangglass 我只有这一个插件,只是设置了两个自定义变量。
   
   ky-ngx-vars.py
   ```lua
   local ngx = ngx
   local core = require("apisix.core")
   
   local schema = {
       type = "object",
       properties = {},
       required = {}
   }
   
   local metadata_schema = {
       type = "object",
       properties = {},
       required = {}
   }
   
   local plugin_name = "ky-ngx-vars"
   
   local _M = {
       version = 0.1,
       priority = 0,        -- TODO: add a type field, may be a good idea
       name = plugin_name,
       schema = schema
   }
   
   
   function _M.check_schema(conf, schema_type)
       if schema_type == core.schema.TYPE_METADATA then
           return core.schema.check(metadata_schema, conf)
       end
       return core.schema.check(schema, conf)
   end
   
   
   function _M.before_proxy(conf, ctx)
       ngx.var.route_name = ctx.matched_route.value.name
       ngx.var.upstream_name = ctx.matched_upstream.name
   
       core.log.debug("set $route_name=", ngx.var.route_name)
       core.log.debug("set $upstream_name=", ngx.var.upstream_name)
   end
   
   
   return _M
   
   ```


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


Reply via email to