Skip to content

Instantly share code, notes, and snippets.

@airy
Forked from rkh/my_app.rb
Created May 6, 2014 15:59
Show Gist options
  • Save airy/6cf9840fc1ffa5ebb796 to your computer and use it in GitHub Desktop.
Save airy/6cf9840fc1ffa5ebb796 to your computer and use it in GitHub Desktop.
require 'sinatra/base'
class MyApp < Sinatra::Base
@@my_app = {}
def self.new(*) self < MyApp ? super : Rack::URLMap.new(@@my_app) end
def self.map(url) @@my_app[url] = self end
class FooController < MyApp
map '/foo'
get '/' do
"foo"
end
end
class BarController < MyApp
map '/bar'
get '/' do
"bar"
end
end
run! if __FILE__ == $0
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment