Route parameters have more precedence than query string arguments
This commit is contained in:
parent
8b1447b68d
commit
77356f7f43
2 changed files with 11 additions and 1 deletions
|
@ -21,6 +21,16 @@ describe "Frank::Handler" do
|
||||||
response.body.should eq("hello world")
|
response.body.should eq("hello world")
|
||||||
end
|
end
|
||||||
|
|
||||||
|
it "route parameter has more precedence than query string arguments" do
|
||||||
|
frank = Frank::Handler.new
|
||||||
|
frank.add_route "GET", "/:message" do |ctx|
|
||||||
|
"hello #{ctx.params["message"]}"
|
||||||
|
end
|
||||||
|
request = HTTP::Request.new("GET", "/world?message=coco")
|
||||||
|
response = frank.call(request)
|
||||||
|
response.body.should eq("hello world")
|
||||||
|
end
|
||||||
|
|
||||||
it "sets content type" do
|
it "sets content type" do
|
||||||
frank = Frank::Handler.new
|
frank = Frank::Handler.new
|
||||||
frank.add_route "GET", "/" do |env|
|
frank.add_route "GET", "/" do |env|
|
||||||
|
|
|
@ -25,7 +25,7 @@ class Frank::Handler < HTTP::Handler
|
||||||
if params
|
if params
|
||||||
if query = uri.query
|
if query = uri.query
|
||||||
CGI.parse(query) do |key, value|
|
CGI.parse(query) do |key, value|
|
||||||
params[key] = value
|
params[key] ||= value
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue