Skip to content

Instantly share code, notes, and snippets.

@jamiehodge
Created November 30, 2011 08:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jamiehodge/1408464 to your computer and use it in GitHub Desktop.
Save jamiehodge/1408464 to your computer and use it in GitHub Desktop.
Nested Sinatra resources
require 'sinatra/base'
class Foo < Sinatra::Base
get '/' do
'foo'
end
get '/:id' do
params.inspect
end
end
class Routes < Sinatra::Base
get '/' do
'hello'
end
get '/biz/:biz_id/foo/?*' do
request.path_info =~ %r{^/biz/\d*?(/foo)(/.*)}
params.delete('splat')
Foo.call(env.merge! 'SCRIPT_NAME' => $1, 'PATH_INFO' => $2, 'rack.request.query_hash' => params)
end
run!
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment