Class: Rack::LocationModifier
- Inherits:
-
Object
- Object
- Rack::LocationModifier
- Defined in:
- lib/rack/cname_request.rb
Instance Attribute Summary collapse
-
#cname_header_value ⇒ Object
readonly
Returns the value of attribute cname_header_value.
-
#host_whitelist ⇒ Object
readonly
Returns the value of attribute host_whitelist.
-
#location_uri ⇒ Object
readonly
Returns the value of attribute location_uri.
Instance Method Summary collapse
-
#initialize(location, cname_header_value, host_whitelist: []) ⇒ LocationModifier
constructor
A new instance of LocationModifier.
- #modified_location ⇒ Object
- #should_modify? ⇒ Boolean
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_value ⇒ Object (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_whitelist ⇒ Object (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_uri ⇒ Object (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_location ⇒ Object
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
37 38 39 |
# File 'lib/rack/cname_request.rb', line 37 def should_modify? comes_from_cname_proxy? && location_host_in_white_list? end |