undying commented on code in PR #12187:
URL: https://github.com/apache/apisix/pull/12187#discussion_r2137220282
##########
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:
I've checked that [pat
regex](https://github.com/apache/apisix/blob/master/apisix/core/utils.lua#L298C19-L298C45)
is [working this way](https://regex101.com/r/LJgPIo/1).
But anyway, I deleted the documentation based on Baoyuantop's recommendation.
--
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]