Class: Skypager::Proxy::RequestProxy

Inherits:
Rack::Proxy
  • Object
show all
Defined in:
lib/skypager/proxy.rb

Instance Method Summary collapse

Instance Method Details

#cfgObject



180
181
182
# File 'lib/skypager/proxy.rb', line 180

def cfg
  @cfg ||= {}
end

#rewrite_env(e) ⇒ Object



184
185
186
187
188
189
190
191
192
193
194
195
196
# File 'lib/skypager/proxy.rb', line 184

def rewrite_env(e)
  e.tap do |env|
    current = env['HTTP_HOST']

    current_host, current_port = current.split(':')

    host = cfg[:host].to_s
    host = host + ":#{ cfg[:port] }" if cfg[:port]

    Rails.logger.info "replacing #{ current } with #{ host } #{ env['PATH_INFO'] }"
    env['HTTP_HOST'] = host
  end
end

#set_config(options = {}) ⇒ Object



175
176
177
178
# File 'lib/skypager/proxy.rb', line 175

def set_config options={}
  cfg.merge!(options)
  cfg
end