Spine::Routing

Gem Version Dependency Status Test Coverage Code Climate security Inline docs Codeship Status for rspine/routing

Router for Rack application. Supports scopes, path parameters and HTTP verbs (GET, POST, PUT, PATCH, DELETE).

Installation

To install it, add the gem to your Gemfile:

gem 'spine-routing'

Then run bundle. If you're not using Bundler, just gem install spine-routing.

Usage

router = Spine::Routing::Router.new
router.configure do
  scope :users do
    get '', to: Users::List
    post ':id', to: Users::Add
  end

  get :status, to: -> (env) { [200, {}, []] }
end

router.call(env)

For getting parameters use env['router.parameters'] or include Spine::Routing::Parameters to your controller/action.