Created
July 27, 2016 06:25
-
-
Save nownabe/ba1bd98f540b98e2619ed7b785072a44 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
# frozen_string_literal: true | |
require "sinatra" | |
module Sinatra | |
module Mount | |
def mount(app, path = "/#{app.name.downcase}") | |
%i(get post put delete patch options).each do |method| | |
self.send(method, "#{path}*") do | |
app.call( | |
env.merge!( | |
"SCRIPT_NAME" => path.split("/").last, | |
"PATH_INFO" => params.delete("splat").join("/") | |
) | |
) | |
end | |
end | |
end | |
end | |
register Mount | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment