Class: Rack::LocationModifier

Inherits:
Object
  • Object
show all
Defined in:
lib/rack/cname_request.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(location, cname_header_value, host_whitelist: []) ⇒ LocationModifier

Returns a new instance of LocationModifier.



31
32
33
34
35
# File 'lib/rack/cname_request.rb', line 31

def initialize(location, cname_header_value, host_whitelist: [])
  @location_uri = URI(location) if location
  @cname_header_value = cname_header_value
  @host_whitelist = host_whitelist || []
end

Instance Attribute Details

#cname_header_valueObject (readonly)

Returns the value of attribute cname_header_value.



29
30
31
# File 'lib/rack/cname_request.rb', line 29

def cname_header_value
  @cname_header_value
end

#host_whitelistObject (readonly)

Returns the value of attribute host_whitelist.



29
30
31
# File 'lib/rack/cname_request.rb', line 29

def host_whitelist
  @host_whitelist
end

#location_uriObject (readonly)

Returns the value of attribute location_uri.



29
30
31
# File 'lib/rack/cname_request.rb', line 29

def location_uri
  @location_uri
end

Instance Method Details

#modified_locationObject



41
42
43
44
# File 'lib/rack/cname_request.rb', line 41

def modified_location
  location_uri.host = cname_header_value
  location_uri.to_s
end

#should_modify?Boolean

Returns:

  • (Boolean)


37
38
39
# File 'lib/rack/cname_request.rb', line 37

def should_modify?
   comes_from_cname_proxy? && location_host_in_white_list?
end