Permalink
Browse files

Automatically insert 'http://' if needed.

  • Loading branch information...
1 parent 26b5340 commit 05e6ffcb2f9a2669a8fa1bde9b755857814265e8 @cespare committed Jul 25, 2012
Showing with 11 additions and 3 deletions.
  1. +9 −1 bin/ez-nginx-proxy
  2. +2 −2 example_config.rb
View
@@ -21,7 +21,7 @@ options = Trollop.options do
[
["/foo/bar", "localhost:1234"], # Route requests to /foo/bar to a local server
- ["/", "amazon.com"] # / matches every request
+ ["/", "amazon.com"] # / matches every request
]
Usage:
@@ -76,6 +76,14 @@ unless match && match.size == 2
end
config_dir = File.dirname(match[1])
+routes.map! do |pattern, target|
+ if target =~ %r{://}
+ [pattern, target]
+ else
+ [pattern, "http://#{target}"]
+ end
+end
+
routes.each do |pattern, target|
puts "Proxying `#{pattern}` to #{target}".green
end
View
@@ -1,4 +1,4 @@
[
- ["/foo/bar", "http://localhost:1234"],
- ["/", "http://localhost:5678"]
+ ["/foo/bar", "localhost:1234"],
+ ["/", "localhost:5678"]
]

0 comments on commit 05e6ffc

Please sign in to comment.