Skip to content

Instantly share code, notes, and snippets.

@mscottford
Created March 9, 2012 21:48
Show Gist options
  • Save mscottford/2008884 to your computer and use it in GitHub Desktop.
Save mscottford/2008884 to your computer and use it in GitHub Desktop.
# This file is used by Rack-based servers to start the application.
map '/' do
require ::File.expand_path('../config/environment', __FILE__)
run LocomotiveInstance::Application
end
# This class reverses environment modifications that were performed by Rack::URLMap
class RestoreScriptAndPathInfo
def initialize(app)
@app = app
end
def call(env)
path = env["PATH_INFO"]
script_name = env['SCRIPT_NAME']
env.merge!('SCRIPT_NAME' => '', 'PATH_INFO' => path + script_name)
return @app.call(env)
end
end
map '/sekret-path' do
require ::File.expand_path('../config/environment', __FILE__)
use Rack::Auth::Basic do |username, password|
[username, password] == ['sekret', 'obfuscated-password']
end
use RestoreScriptAndPathInfo
run LocomotiveInstance::Application
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment