【问题标题】:How do you make Rails route everything under a path to a Rack app?如何让 Rails 将路径下的所有内容路由到 Rack 应用程序?
【发布时间】:2011-04-02 14:48:33
【问题描述】:

我正在尝试捕获对/dav 的所有请求以及嵌套在其下的所有路径到机架处理程序:

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

我真的必须为此制定两条路线,还是有办法将其表达为一条路线(一条线)?

【问题讨论】:

    标签: ruby-on-rails rack


    【解决方案1】:

    我觉得应该够用了

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

    可选参数在“Bound parameters”下的 Rails 路由指南中进行了非常简要的描述

    【讨论】:

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

      【讨论】:

        猜你喜欢
        • 2017-03-07
        • 2011-09-03
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2011-08-04
        • 2014-11-28
        相关资源
        最近更新 更多