Created
March 9, 2012 21:48
-
-
Save mscottford/2008884 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
# 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