Class: Rack::CnameRequest
- Inherits:
-
Object
- Object
- Rack::CnameRequest
- Defined in:
- lib/rack/cname_request.rb,
lib/rack/cname_request/version.rb
Constant Summary collapse
- VERSION =
'0.1.3'
Instance Attribute Summary collapse
-
#host_whitelist ⇒ Object
readonly
Returns the value of attribute host_whitelist.
-
#http_cname_header_key ⇒ Object
readonly
Returns the value of attribute http_cname_header_key.
Instance Method Summary collapse
- #call(env) ⇒ Object
-
#initialize(app, cname_header_key: nil, only: []) ⇒ CnameRequest
constructor
A new instance of CnameRequest.
Constructor Details
#initialize(app, cname_header_key: nil, only: []) ⇒ CnameRequest
Returns a new instance of CnameRequest.
8 9 10 11 12 |
# File 'lib/rack/cname_request.rb', line 8 def initialize(app, cname_header_key: nil, only: []) @app = app @http_cname_header_key = "HTTP_#{cname_header_key}" @host_whitelist = only || [] end |
Instance Attribute Details
#host_whitelist ⇒ Object (readonly)
Returns the value of attribute host_whitelist.
6 7 8 |
# File 'lib/rack/cname_request.rb', line 6 def host_whitelist @host_whitelist end |
#http_cname_header_key ⇒ Object (readonly)
Returns the value of attribute http_cname_header_key.
6 7 8 |
# File 'lib/rack/cname_request.rb', line 6 def http_cname_header_key @http_cname_header_key end |
Instance Method Details
#call(env) ⇒ Object
14 15 16 17 18 19 20 21 22 23 |
# File 'lib/rack/cname_request.rb', line 14 def call(env) status, headers, body = @app.call env original_location = headers['Location'] if original_location modifier = LocationModifier.new(original_location, env[http_cname_header_key], host_whitelist: host_whitelist) headers['Location'] = modifier.modified_location if modifier.should_modify? end [status, headers, body] end |