SinatraSimpleRouter
Simple routing abstraction to Sinatra applications.
Installation
Add this line to your application's Gemfile:
gem 'sinatra_simple_router'
And then execute:
$ bundle
Or install it yourself as:
$ gem install sinatra_simple_router
Usage
require "sinatra"
require "sinatra_simple_router"
class UsersController < SinatraSimpleRouter::Controller
def show
@user = User.find(params[:id])
erb :"users/show"
end
def update
@user = User.find(params[:id])
@user.update_attributes(params[:user])
redirect "/users/#{@user.id}"
end
end
class Application < Sinatra::Base
include SinatraSimpleRouter
match :get, "/users/:id", UsersController, :show
match :patch, "/users/:id", UsersController, :update
end
Missing features
- Support before/after filters
- Named routes + Helpers
- Support more than one method (such as: match [:patch, :put] ...)
Contributing
- Fork it
- Create your feature branch (
git checkout -b my-new-feature) - Commit your changes (
git commit -am 'Add some feature') - Push to the branch (
git push origin my-new-feature) - Create new Pull Request