开发者

How do you make Rails route everything under a path to a Rack app?

开发者 https://www.devze.com 2023-02-21 20:11 出处:网络
I\'m trying to capture all requests to /dav and all paths nested under that to a Rack handler: match \"/dav\" =>RackDAV::Handler.new(:root => \'davdocs\')

I'm trying to capture all requests to /dav and all paths nested under that to a Rack handler:

match "/dav" =>  RackDAV::Handler.new(:root => 'davdocs')
match "/dav/*whatever" =>  RackDAV::Handler.new(:root => 'davdocs')

Do I really have to mak开发者_高级运维e two routes for this, or is there a way to express this as one route (one line)?


I think it should be enough to use

match "/dav(/*whatever)" =>  RackDAV::Handler.new(:root => 'davdocs')

Optional parameters are very briefly described in the Rails Routing guide under "Bound parameters"


match '/dav(/*dav_section)', :to =>  Proc.new { |env| [200, {"Content-Type" => 'text/plain'},["Here we are in Dav"]]}
0

精彩评论

暂无评论...
验证码 换一张
取 消