class ImagesProxy
Constants
- HOST
- NEED_FAKE
Public Class Methods
new(app)
click to toggle source
# File lib/c80_shared/middleware/images_proxy.rb, line 22 def initialize(app) @app = app end
Public Instance Methods
call(env)
click to toggle source
# File lib/c80_shared/middleware/images_proxy.rb, line 26 def call(env) original_host = env['HTTP_HOST'] rewrite_env(env) if env['HTTP_HOST'] != original_host perform_request(env) else # just regular @app.call(env) end end
rewrite_env(env)
click to toggle source
# File lib/c80_shared/middleware/images_proxy.rb, line 37 def rewrite_env(env) path = Rack::Request.new(env).path if path =~ NEED_FAKE && !File.exists?(path) env['HTTP_HOST'] = HOST env['SERVER_PORT'] = 80 else # do nothing end env end