Skip to content
Browse files

Allow origin server to be dynamically configured by env key

  • Loading branch information...
1 parent 3d12197 commit 013c543331bd78dbd7a217eeb99f828492355c78 @josh josh committed with Dec 17, 2009
Showing with 8 additions and 2 deletions.
  1. +6 −0 config.ru
  2. +1 −1 image_server.rb
  3. +1 −1 lib/middleware/remote_proxy.rb
View
6 config.ru
@@ -6,6 +6,12 @@ require 'rack/contrib'
require 'image_server'
require 'config/env'
+
+use Rack::Config do |env|
+ env['imagery.origin_host'] = ORIGIN_SERVER
+end
+
+
# Add rack sendfile extension.
# Allows us to serve cache hits directly from file system
# by nginx (big speed boost). read:
View
2 image_server.rb
@@ -19,7 +19,7 @@ def call(env)
Logger.current.info 'Attempting to generate missing file...'
[SvgGenerator, ImageVariantGenerator].each do |generator|
- if image = generator.from_url(ORIGIN_SERVER, env['PATH_INFO'] + (env['QUERY_STRING'].empty? ? '' : "?#{env['QUERY_STRING']}"))
+ if image = generator.from_url(env['imagery.origin_host'], env['PATH_INFO'] + (env['QUERY_STRING'].empty? ? '' : "?#{env['QUERY_STRING']}"))
return send_file(image)
end
View
2 lib/middleware/remote_proxy.rb
@@ -9,7 +9,7 @@ def initialize(app)
def call(env)
request = Rack::Request.new(env)
- requested_file = Image.new(ORIGIN_SERVER, env['PATH_INFO'] + (env['QUERY_STRING'].empty? ? '' : "?#{env['QUERY_STRING']}"))
+ requested_file = Image.new(env['imagery.origin_host'], env['PATH_INFO'] + (env['QUERY_STRING'].empty? ? '' : "?#{env['QUERY_STRING']}"))
# If file exists we simply sent it to the client.
if requested_file.found?

0 comments on commit 013c543

Please sign in to comment.
Something went wrong with that request. Please try again.