You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Returns a Lua table holds all of the current request's request URL query arguments.
953
+
954
+
Here's an example,
955
+
956
+
location = /test {
957
+
content_by_lua '
958
+
local args = ngx.req.get_query_args()
959
+
for key, val in pairs(args) do
960
+
if type(val) == "table" then
961
+
ngx.say(key, ": ", table.concat(val, ", "))
962
+
else
963
+
ngx.say(key, ": ", val)
964
+
end
965
+
end
966
+
';
967
+
}
968
+
969
+
Then `GET /test?foo=bar&bar=baz&bar=blah` will yield the response body
970
+
971
+
foo: bar
972
+
bar: baz, blah
973
+
974
+
Multiple occurrences of an argument key will result in a table value holding all of the values for that key in order.
975
+
976
+
Keys and values will be automatically unescaped according to URI escaping rules. For example, in the above settings, `GET /test?a%20b=1%61+2` will yield the output
977
+
978
+
a b: 1a 2
979
+
980
+
Arguments without the `=<value>` parts are treated as boolean arguments. For example, `GET /test?foo&bar` will yield the outputs
981
+
982
+
foo: true
983
+
bar: true
984
+
985
+
That is, they will take Lua boolean values `true`. However, they're different from arguments taking empty string values. For example, `GET /test?foo=&bar=` will give something like
986
+
987
+
foo:
988
+
bar:
989
+
990
+
Empty key arguments are discarded, for instance, `GET /test?=hello&=world will yeild empty outputs.
991
+
992
+
Updating query arguments via the nginx variable `$args` (or `ngx.var.args` in Lua) at runtime are also supported:
0 commit comments