Class: Rack::TldLength
- Inherits:
-
Object
- Object
- Rack::TldLength
- Defined in:
- lib/rack/tld_length.rb
Instance Method Summary collapse
- #call(env) ⇒ Object
-
#initialize(app, host_pattern, host_tld_length) ⇒ TldLength
constructor
A new instance of TldLength.
Constructor Details
#initialize(app, host_pattern, host_tld_length) ⇒ TldLength
Returns a new instance of TldLength.
3 4 5 6 7 |
# File 'lib/rack/tld_length.rb', line 3 def initialize(app, host_pattern, host_tld_length) @app = app @host_pattern = Regexp.new(host_pattern) @host_tld_length = host_tld_length end |
Instance Method Details
#call(env) ⇒ Object
9 10 11 12 13 14 15 16 17 18 19 |
# File 'lib/rack/tld_length.rb', line 9 def call(env) original_tld_length = tld_length request = Rack::Request.new(env) set_tld_length(@host_tld_length) if request.host =~ @host_pattern @app.call(env) ensure set_tld_length(original_tld_length) end |