Rack::Cascade and Modular Sinatra Applications
# app.rb
require 'sinatra/base'
class Banana < Sinatra::Base
get('/banana') { '🍌' }
end
class Broccoli < Sinatra::Base
get('/broccoli') { '🥦' }
end
class Bacon < Sinatra::base
get('/bacon') { '🥓' }
end
# config.ru
require 'rubygems'
require 'bundler'
Bundler.setup(:default)
require './app'
run Rack::Cascade.new [Banana, Broccoli, Bacon]
# Gemfile
source 'https://rubygems.org'
gem 'sinatra'
$ bundle
$ rackup
Visit localhost:9292/broccoli.