Skip to content

Instantly share code, notes, and snippets.

@nownabe
Created July 27, 2016 06:25
Show Gist options
  • Save nownabe/ba1bd98f540b98e2619ed7b785072a44 to your computer and use it in GitHub Desktop.
Save nownabe/ba1bd98f540b98e2619ed7b785072a44 to your computer and use it in GitHub Desktop.
# 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