Last active
February 27, 2017 14:14
-
-
Save porras/fc0b305ab2e9d10f94c8e39ada329a0e to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'sinatra/base' | |
class A < Sinatra::Base | |
get '/this' do | |
'this from A' | |
end | |
end | |
class B < Sinatra::Base | |
get '/that' do | |
'that from B' | |
end | |
end | |
class Rack::Chain | |
def initialize(*apps) | |
@apps = apps | |
end | |
def call(env) | |
@apps.each do |app| | |
status, headers, body = app.call(env) | |
return [status, headers, body] unless status == 404 | |
end | |
[404, {}, ['No app matched']] | |
end | |
end | |
run Rack::Chain.new(A, B) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment