Created
September 11, 2012 05:18
-
-
Save seratch/3696130 to your computer and use it in GitHub Desktop.
Redirect Rack app
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
| def redirect(arg) | |
| new_host = 'new.example.com' | |
| uri = arg["REQUEST_URI"] | |
| [ | |
| 302, | |
| {'content-type' => 'text/plain', 'location' => "http://#{new_host}#{uri}"}, | |
| "http://#{new_host}#{uri}".chars | |
| ] | |
| end | |
| run method(:redirect) | |
| # rackup -p 3000 -D |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment