Closed MiaoZhou closed 9 years ago
@MiaoZhou thanks for raising this point!
This is hard topic, as every library/framework tend to do things differently.
I believe if two inputs with the same name are sent, the last one should win because thats how Ruby Rack does it. To send arrays, there is name[]
convention, that treats all the params as an array.
Would it make sense to have it configurable? Just extract the merge strategy to a function and expose it as rack.merge_params
.
@mikz thanks for your reply.
I use r:match()
in my main.lua
file. The code like this:
r:match({
get = {
['/foo'] = function(params) funcA(params) end,
['/foo/bar'] = function(params) funcB(params) end
},
post = {
['/foo'] = function(params) funcC(params) end,
['/foo/bar'] = function(params) funcD(params) end
})
The main.lua
file only dispatch request to different lua modules that handle with specific logical things.
To make the code clean and neat, i passed all get
or post
args as r:excute()
's third param depending on what ngx.req.get_method()
returned.
That's what i got an error. It's my implementation cause this. There's no need to merge this commit.
Thanks again for making me think more.
When handle with:
/test?foo=bar&bar=baz&bar=blah
foo=bar&bar=baz&bar=blah
params
(first passingt
to copy()) should be {foo = "bar", bar = {"baz", "blah"}}.The excute will throw an
attempt to index local 'visited' (a nil value)
error.