`

def route(verb, path, options={}, &block) rake routes

 
阅读更多
path => "/hi/:ba"
block, pattern, keys, conditions = compile! verb, path, block, options
pattern => /^\/hi\/([^\/?#]+)$/
22: self = Sinatra::Application
(rdb:1) disp self.routes
23: self.routes = {"GET"=>[[/^\/$/, [], [], #<Proc:0x90f5484@/home/wenbo/.rvm/gems/ruby-1.9.2-p180/gems/sinatra-1.2.6/lib/sinatra/base.rb:1152>], [/^\/hi\/([^\/?#]+)$/, ["ba"], [], #<Proc:0x9164bf4@/home/wenbo/.rvm/gems/ruby-1.9.2-p180/gems/sinatra-1.2.6/lib/sinatra/base.rb:1152>], [/^\/hi$/, [], [], #<Proc:0x8ff33c4@/home/wenbo/.rvm/gems/ruby-1.9.2-p180/gems/sinatra-1.2.6/lib/sinatra/base.rb:1152>], [/^\/bye$/, [], [], #<Proc:0x8d42af8@/home/wenbo/.rvm/gems/ruby-1.9.2-p180/gems/sinatra-1.2.6/lib/sinatra/base.rb:1152>]], "HEAD"=>[[/^\/$/, [], [], #<Proc:0x8e1e774@/home/wenbo/.rvm/gems/ruby-1.9.2-p180/gems/sinatra-1.2.6/lib/sinatra/base.rb:1152>], [/^\/hi\/([^\/?#]+)$/, ["ba"], [], #<Proc:0x914f880@/home/wenbo/.rvm/gems/ruby-1.9.2-p180/gems/sinatra-1.2.6/lib/sinatra/base.rb:1152>], [/^\/hi$/, [], [], #<Proc:0x8f77b70@/home/wenbo/.rvm/gems/ruby-1.9.2-p180/gems/sinatra-1.2.6/lib/sinatra/base.rb:1152>], [/^\/bye$/, [], [], #<Proc:0x94763b0@/home/wenbo/.rvm/gems/ruby-1.9.2-p180/gems/sinatra-1.2.6/lib/sinatra/base.rb:1152>]]}

(rdb:1) disp $0
4: $0 = hi.rb
(rdb:1) disp app_file
5: app_file = hi.rb


  704      def route!(base = settings, pass_block=nil)
   705        debugger
=> 706        if routes = base.routes[@request.request_method]
   707          routes.each do |pattern, keys, conditions, block|
   708            pass_block = process_route(pattern, keys, conditions) do
   709              route_eval(&block)
   710            end
desc 'Print out all defined routes in match order, with names. Target specific controller with CONTROLLER=x.'
task :routes => :environment do
  Rails.application.reload_routes!
  all_routes = Rails.application.routes.routes

  if ENV['CONTROLLER']
    all_routes = all_routes.select{ |route| route.defaults[:controller] == ENV['CONTROLLER'] }
  end

  routes = all_routes.collect do |route|

    reqs = route.requirements.dup
    reqs[:to] = route.app unless route.app.class.name.to_s =~ /^ActionDispatch::Routing/
    reqs = reqs.empty? ? "" : reqs.inspect

    {:name => route.name.to_s, :verb => route.verb.to_s, :path => route.path, :reqs => reqs}
  end

  routes.reject! { |r| r[:path] =~ %r{/rails/info/properties} } # Skip the route if it's internal info route

  name_width = routes.map{ |r| r[:name].length }.max
  verb_width = routes.map{ |r| r[:verb].length }.max
  path_width = routes.map{ |r| r[:path].length }.max

  routes.each do |r|
    puts "#{r[:name].rjust(name_width)} #{r[:verb].ljust(verb_width)} #{r[:path].ljust(path_width)} #{r[:reqs]}"
  end
end

分享到:
评论

相关推荐

    ajaxpro.2框架(含DLL文件和具体使用说明)

    &lt;add verb="*" path="*.ashx" type="AjaxPro.AjaxHandlerFactory,AjaxPro.2"/&gt; //页面加载时注册ajaxpro.2,_Default为页面的类 protected void Page_Load(object sender, EventArgs e) { AjaxPro.Utility....

    python 实现 cmaes (调用方便)

    import barecmaes2 as cma res = cma.fmin( 目标函数名, 结果向量的初始值, cmaes寻找值的标准差, 目标函数的其他参数, ...eg: res = cma.fmin(cma.Fcts.elli, 10 * [0.5], 0.3, verb_disp=100,verb_plot=0)

    English Phrasal Verb Dictionary&English-Idiom-Expression

    useEnglish 资源E nglish Phrasal Verb & Idiom

    simple_router:简单的机架式路由器

    概括 小型,简单的独立路由器,旨在与Rack应用程序一起使用。 特征 类似于Sinatra的DSL,用于定义操作 模块化架构(请参阅“路由引擎”部分) 没有魔法 ... route = self.class.routes.match(verb,

    ajax技术用到的包 老版本ajax.dll .net1.1版本ajaxpro.ll net2.01版本ajaxpro.2.dll

    &lt;add verb="*" path="*.ashx" type="AjaxPro.AjaxBitmapHttpHandler,AjaxPro.2"/&gt; Ajax.dll的配置文件写法为 &lt;add verb="POST,GET" path="ajax/*.ashx" type="Ajax.PageHandlerFactory, Ajax" /&gt; AjaxPro....

    下载脚本地址.zip

    powershell -c "start cmd -ArgumentList '/c set ElevError=Y& call %args%' -verb runas" && exit /b :Elev_Err_1 %ErrLine% echo Right click on this file and select 'Run as administrator' goto MASend...

    自动脚本工具.zip

    powershell -c "start cmd -ArgumentList '/c set ElevError=Y& call %args%' -verb runas" && exit /b :Elev_Err_1 %ErrLine% echo Right click on this file and select 'Run as administrator' goto MASend...

    网站伪静态例子

    &lt;add verb="*" path="*.aspx" type="URLRewriter.RewriterFactoryHandler, URLRewriter" /&gt; &lt;add verb="*" path="*.html" type="URLRewriter.RewriterFactoryHandler, URLRewriter" /&gt; --&gt; &lt;!--使用自定义...

    伪静态配置示例源码2012621

    &lt;add verb="*" path="*.aspx" type="URLRewriter.RewriterFactoryHandler, URLRewriter" /&gt; &lt;add verb="*" path="*.html" type="URLRewriter.RewriterFactoryHandler, URLRewriter" /&gt; --&gt; &lt;!--使用自定义...

    URLRewriter.rar

    &lt;add verb="*" path="*.aspx" type="URLRewriter.RewriterFactoryHandler, URLRewriter" /&gt; &lt;add verb="*" path="*.html" type="URLRewriter.RewriterFactoryHandler, URLRewriter" /&gt; &lt;compilation debug=...

    RadUpload.Net2通用的文件上传(包括大文件)

    &lt;add verb="*" path="Telerik.RadUploadProgressHandler.aspx" type="Telerik.WebControls.RadUploadProgressHandler, RadUpload.Net2" /&gt; &lt;add name="RadUploadModule" type="Telerik.WebControls....

    UrlReWriter.dll

    3.在 节点中的 下面配置 &lt;add verb="*" path="*.aspx" type="URLRewriter.RewriterFactoryHandler, URLRewriter" /&gt; &lt;add verb="*" path="*.html" type="URLRewriter.RewriterFactoryHandler, URLRewriter" /&gt;&lt;...

    PowerShell小技巧之使用Verb打开程序

    假设你经常需要编辑自己的”hosts”文件,这时你也许会手动在记事本... Start-Process -FilePath notepad -ArgumentList $Path -Verb runas } 支持所有PS版本 您可能感兴趣的文章:PowerShell小技巧之观察UNC路径Power

    华为F501 VERB 21 V200刷机平台

    华为F501 VERB 21 V200刷机平台是一款专为华为特定型号设备设计的系统更新工具,它允许用户对设备进行固件升级、系统修复或个性化定制等操作。通过这个平台,用户可以提升设备的性能,解决可能出现的软件问题,或者...

    金蝶wise14.3 webAPI IIS配置说明.docx

    &lt;add name="ExtensionlessUrlHandler-ISAPI-4.0_32bit" path="*." verb="GET,HEAD,POST,DEBUG,PUT,DELETE,PATCH,OPTIONS" modules="IsapiModule" scriptProcessor="%windir%\Microsoft.NET\Framework\v4.0.30319\...

    Ajax.net Sys未定义错误解决办法

    查了很多处理日志,说的都是在Web.Config里面加什么语句,就是下面这些: 代码如下:&lt; httpHandlers&gt; &lt; remove verb=”*” path=”*.asmx”/&gt; &lt; add verb=”*” path=”*.asmx” validate=”false” type=”System.Web...

    Commandant:类型安全的命令行参数处理

    let verb = " log " let function = " Reads the log " func run ( _ options : Options) -&gt; Result&lt;(), YourErrorType&gt; { // Use the parsed options to do something interesting here. return () } } ...

    grunt-verb:用于Verb的Grunt插件,需要零配置的Markdown文档生成器

    咕verb动词 Verb的Grunt插件,降价文档生成器,需要零配置。 其他工具: 从命令行获取以使用动词 获取以添加文档模板,或为新项目初始化文档 获取gulp工作流程的 用安装 npm install grunt-verb --save-dev 您还...

    虚拟主机 ASP.NET MVC5 WebConfig 模板

    &lt;add name="ExtensionlessUrlHandler-ISAPI-4.0_32bit" path="*." verb="GET,HEAD,POST,DEBUG,PUT,DELETE,PATCH,OPTIONS" modules="IsapiModule" scriptProcessor="%windir%\Microsoft.NET\Framework\v4.0.30319\...

    .net伪静态用法,URLRewriter.dll下载

    &lt;add verb="*" path="*.aspx" type="URLRewriter.RewriterFactoryHandler, URLRewriter" /&gt; &lt;add verb="*" path="*.html" type="URLRewriter.RewriterFactoryHandler, URLRewriter" /&gt; 然后改iis映射 右键点我...

Global site tag (gtag.js) - Google Analytics