class Rack::LocationModifier

Attributes

cname_header_value[R]
host_whitelist[R]
location_uri[R]

Public Class Methods

new(location, cname_header_value, host_whitelist: []) click to toggle source
# File lib/rack/cname_request.rb, line 31
def initialize(location, cname_header_value, host_whitelist: [])
  @location_uri = URI(URI.escape(location)) if location
  @cname_header_value = cname_header_value
  @host_whitelist = host_whitelist || []
end

Public Instance Methods

modified_location() click to toggle source
# File lib/rack/cname_request.rb, line 41
def modified_location
  location_uri.host = cname_header_value
  location_uri.to_s
end
should_modify?() click to toggle source
# File lib/rack/cname_request.rb, line 37
def should_modify?
   comes_from_cname_proxy? && location_host_in_white_list?
end

Private Instance Methods

comes_from_cname_proxy?() click to toggle source
# File lib/rack/cname_request.rb, line 48
def comes_from_cname_proxy?
  cname_header_value
end
location_host_in_white_list?() click to toggle source
# File lib/rack/cname_request.rb, line 52
def location_host_in_white_list?
  host_whitelist.include?(location_uri.host)
end