Module | Sinatra::MultiRoute |
In: |
lib/sinatra/multi_route.rb
|
Create multiple routes with one statement.
Use this extension to create a handler for multiple routes:
get '/foo', '/bar' do # ... end
Or for multiple verbs:
route :get, :post, '/' do # ... end
Or for multiple verbs and multiple routes:
route :get, :post, ['/foo', '/bar'] do # ... end
Or even for custom verbs:
route 'LIST', '/' do # ... end
To use the extension in a classic application all you need to do is require it:
require "sinatra" require "sinatra/multi_route" # Your classic application code goes here...
To use the extension in a modular application you need to require it, and then, tell the application you will use it:
require "sinatra/base" require "sinatra/multi_route" class MyApp < Sinatra::Base register Sinatra::MultiRoute # The rest of your modular application code goes here... end