Router for Rack application. Supports scopes, path parameters and HTTP verbs (GET, POST, PUT, PATCH, DELETE).
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
.
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.