Class: Rack::WwwEnforcer
- Inherits:
-
Object
- Object
- Rack::WwwEnforcer
- Defined in:
- lib/rack/www-enforcer.rb
Instance Method Summary collapse
- #call(env) ⇒ Object
-
#initialize(app, options = {}) ⇒ WwwEnforcer
constructor
A new instance of WwwEnforcer.
Constructor Details
#initialize(app, options = {}) ⇒ WwwEnforcer
Returns a new instance of WwwEnforcer.
7 8 9 10 11 |
# File 'lib/rack/www-enforcer.rb', line 7 def initialize(app, = {}) @app = app @subdomain = [:subdomain] || "www" @replace_subdomain = [:replace_subdomain] end |
Instance Method Details
#call(env) ⇒ Object
13 14 15 16 17 18 19 20 |
# File 'lib/rack/www-enforcer.rb', line 13 def call(env) req = Request.new(env) if subdomain_present?(req) @app.call(env) else redirect_to_subdomain(req) end end |