Skip to content

Instantly share code, notes, and snippets.

@TheML9I
Created November 1, 2016 05:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save TheML9I/436fd28c60f7ddfe3a5fa6608d73cdae to your computer and use it in GitHub Desktop.
Save TheML9I/436fd28c60f7ddfe3a5fa6608d73cdae to your computer and use it in GitHub Desktop.
Nginx lua. Make a list of args of request
function get_args_str()
local args_str = "?"
local keys = {}
if #args < 0 then
return ""
end
for key, val in pairs(args) do
table.insert(keys, key)
end
local len_keys = #keys
for i, key in ipairs(keys) do
local val = args[key]
if type(val) == "table" then
local len_val = #val
for j, val in ipairs(val) do
args_str = args_str..key.."="..val
if j < len_val then
args_str = args_str.."&"
end
end
else
args_str = args_str..key.."="..val
if i < len_keys then
args_str = args_str.."&"
end
end
end
return args_str
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment