Class: Rack::EnsureProperHost
- Inherits:
-
Object
- Object
- Rack::EnsureProperHost
- Defined in:
- lib/rack/ensure_proper_host.rb,
lib/rack/ensure_proper_host/version.rb
Constant Summary collapse
- VERSION =
"0.1.0"
Instance Method Summary collapse
- #call(env) ⇒ Object
-
#initialize(app, *hosts) ⇒ EnsureProperHost
constructor
A new instance of EnsureProperHost.
Constructor Details
#initialize(app, *hosts) ⇒ EnsureProperHost
Returns a new instance of EnsureProperHost.
6 7 8 9 |
# File 'lib/rack/ensure_proper_host.rb', line 6 def initialize(app, *hosts) @app = app @hosts = hosts.flatten end |
Instance Method Details
#call(env) ⇒ Object
11 12 13 14 15 16 17 18 |
# File 'lib/rack/ensure_proper_host.rb', line 11 def call(env) @host = env['HTTP_HOST'] if @hosts.include?(@host) @app.call(env) else [ 301, request_with_proper_host(env), [ "Moved Permanently\n" ]] end end |