2.18.0.txt

doc/release_notes/2.18.0.txt
Last Update: 2016-09-13 12:20:48 -0700

New Plugins

  • A static_routing plugin has been added, which can give a 3-4x increase in performance for large number of static routes, and makes routing O(1) for static routes. Static routes are routes that match full paths, with no placeholders, and are checked before using the normal routing tree.

    Static routes are defined via class-level static_* routing methods. There is a static_* routing method for each HTTP verb (e.g. static_get), as well as a static_route method, which will work for any HTTP verb, with the verb-specific method taking priority. By using static_route, you can get significantly faster performance while retaining some of the benefits of Roda’s routing tree design (simple shared logic with verb specific behavior). Example:

    plugin :static_routing
    
    static_route '/foo' do |r|
      @var = :foo
    
      r.get do
        'Not actually reached'
      end
    
      r.post{'static POST /#{@var}'}
    end
    
    static_get '/foo' do |r|
      'static GET /foo'
    end
    
    route do |r|
      'Not a static route'
    end
    

    Because static routing routes on the full path instead of by path segment, the methods takes the full path as a string, including the leading slash.

  • An assets_preloading plugin has been added, which makes it simple to generate HTML link tags or a Link header value to tell the browser to preload assets for performance reasons.

    # In routes, using the Link header:
    response.headers['Link'] = preload_assets_link_header(:css)
    
    # In templates, using a link tag:
    <%= preload_assets_link_tags(:css) %>

New Features

  • RodaRequest#real_remaining_path has been added. This is designed to be overridden by plugins that modify remaining_path for internal routing purposes. RodaRequest#run now uses real_remaining_path when passing requests to other rack applications.

  • An assets_paths method has been added to the assets plugin. This is similar to the assets method, but it returns an array of paths to the assets, instead of a HTML link/script tag.

Other Improvements

  • The public plugin now works correctly when used with the type_routing plugin, for paths ending in extensions that type_routing is configured to handle.

  • The head plugin now works with the not_allowed plugin if it is loaded after the not_allowed plugin.