Skip to content

Instantly share code, notes, and snippets.

@jamiehodge
Created April 10, 2012 14:31
Show Gist options
  • Save jamiehodge/2351768 to your computer and use it in GitHub Desktop.
Save jamiehodge/2351768 to your computer and use it in GitHub Desktop.
sinatra/mount
module Sinatra
module Mount
def mount(app, route="/#{app.name.downcase}")
%w{get post put delete patch options}.each do |method|
self.send method.to_sym, "#{route}*" do
app.call(
env.merge!(
'SCRIPT_NAME' => route.split('/').last,
'PATH_INFO' => params.delete('splat').join('/')
)
)
end
end
end
end
register Mount
end
@merqlove
Copy link

Looks it working well :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment