bzp2010 commented on code in PR #12187: URL: https://github.com/apache/apisix/pull/12187#discussion_r2132207021
########## apisix/core/utils.lua: ########## @@ -337,6 +337,24 @@ do end end -- Resolve ngx.var in the given string +-- @function core.utils.resolve_var +-- @tparam string tpl The template string to resolve variables in +-- @tparam table ctx The context table containing variables +-- @tparam function escaper Optional function to escape resolved values +-- @treturn string The resolved string +-- @treturn string|nil Error message if any +-- @treturn number Number of variables replaced +-- @usage +-- local utils = require("apisix.core.utils") +-- +-- -- Usage examples: +-- local res = utils.resolve_var("$host", ctx.var) -- "example.com" +-- local res = utils.resolve_var("${host}", ctx.var) -- "example.com" +-- local res = utils.resolve_var("TMP_${VAR1}_${VAR2}", ctx.var) -- "TMP_value1_value2" +-- local res = utils.resolve_var("\\$host", ctx.var) -- "$host" +-- +-- -- Usage in APISIX context: +-- local service_name = utils.resolve_var(up_conf.service_name, api_ctx.var) Review Comment: Remove it and the IDE will tell us the reference without having to document it. ########## apisix/core/utils.lua: ########## @@ -337,6 +337,24 @@ do end end -- Resolve ngx.var in the given string +-- @function core.utils.resolve_var +-- @tparam string tpl The template string to resolve variables in +-- @tparam table ctx The context table containing variables +-- @tparam function escaper Optional function to escape resolved values +-- @treturn string The resolved string +-- @treturn string|nil Error message if any +-- @treturn number Number of variables replaced +-- @usage +-- local utils = require("apisix.core.utils") +-- +-- -- Usage examples: +-- local res = utils.resolve_var("$host", ctx.var) -- "example.com" +-- local res = utils.resolve_var("${host}", ctx.var) -- "example.com" +-- local res = utils.resolve_var("TMP_${VAR1}_${VAR2}", ctx.var) -- "TMP_value1_value2" +-- local res = utils.resolve_var("\\$host", ctx.var) -- "$host" Review Comment: Have you already confirmed this? I mean, do the escaping. -- 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-unsubscr...@apisix.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org