Skip to content

Instantly share code, notes, and snippets.

@porras
Last active February 27, 2017 14:14
Show Gist options
  • Save porras/fc0b305ab2e9d10f94c8e39ada329a0e to your computer and use it in GitHub Desktop.
Save porras/fc0b305ab2e9d10f94c8e39ada329a0e to your computer and use it in GitHub Desktop.
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