Created
September 10, 2011 03:54
-
-
Save lfborjas/1207894 to your computer and use it in GitHub Desktop.
Simple proxy server for developing front-ends for APIs (using rack middleware)
This file contains 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
require 'rack' | |
require 'rack/proxy' #gem install rack-proxy | |
class Proxy < Rack::Proxy | |
def rewrite_env(env) | |
env["HTTP_HOST"] = "my.host.com" | |
env["SERVER_PORT"] = "80" | |
env | |
end | |
end | |
#serve static assets, your frontend | |
use Rack::Static, :urls => {"/" => "index.html"} | |
use Rack::Static, :urls => ["/css", "/images", "/js"] | |
run Proxy.new | |
#thin --rackup proxy.ru start |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment