Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

misc cleanup

  • Loading branch information...
commit 1f61a5e5469d9935720c566345d0bfc4fae1cc64 1 parent 7dfa755
Tobias Lütke authored
Showing with 9 additions and 22 deletions.
  1. +2 −19 api_proxy.rb
  2. +2 −2 lib/proxy_endpoint.rb
  3. +5 −1 lib/request.rb
View
21 api_proxy.rb
@@ -9,19 +9,6 @@
$cache = Memcached.new('localhost:11211')
-class Util
-
- def self.generate_key
- "proxy-content/#{crc32([Time.now, rand, @uri].join)}"
- end
-
- def self.crc32(content)
- Zlib.crc32(content, 0)
- end
-
-end
-
-
Proxy.start(:host => "0.0.0.0", :port => 3005) do |conn|
conn.server :shopify, :host => "127.0.0.1", :port => 80
@@ -30,11 +17,7 @@ def self.crc32(content)
request = Request.new(data)
if request.path =~ /^\/proxy/
-
-
- forwarder = Forwarder.new
- forwarder.forward(request)
-
+
proxy = ProxyEndpoint.new(request.request_uri)
if proxy.available?
@@ -52,7 +35,7 @@ def self.crc32(content)
request.data
else
- # ...
+ request.data
end
end
View
4 lib/proxy_endpoint.rb
@@ -13,8 +13,8 @@ class MethodNotAllowed < Error; end
ProxyRoot = /https?\:\/\/.*?\/[\w_-]+\/[\w_-]+/
def initialize(uri)
- @uri = uri
- @proxy_root = uri.scan(ProxyRoot).flatten.first
+ @uri = uri.to_s
+ @proxy_root = @uri.scan(ProxyRoot).flatten.first
if @proxy_root.nil?
raise Error, "could not find proxy root for url"
View
6 lib/request.rb
@@ -14,7 +14,11 @@ def initialize(data)
def content_type
headers['Content-Type']
- end
+ end
+
+ def request_uri
+ headers['HTTP_REQUEST_URI']
+ end
def headers
@headers ||= @data.scan(Headers).inject(Hash.new) do |hash, (k, v)|
Please sign in to comment.
Something went wrong with that request. Please try again.