Class: Namira::Middleware::Redirector
- Inherits:
-
Object
- Object
- Namira::Middleware::Redirector
- Defined in:
- lib/namira/middleware/redirector.rb
Overview
Performs following the redirect and handling multiple redirect errors.
Constant Summary collapse
- REDIRECT_STATUS =
The HTTP status codes Namira will consider a redirect
[301, 302].freeze
Instance Method Summary collapse
-
#call(env) ⇒ Object
Called by the middleware runner.
-
#initialize(app) ⇒ Redirector
constructor
A new instance of Redirector.
Constructor Details
#initialize(app) ⇒ Redirector
10 11 12 |
# File 'lib/namira/middleware/redirector.rb', line 10 def initialize(app) @app = app end |
Instance Method Details
#call(env) ⇒ Object
Called by the middleware runner.
18 19 20 21 22 23 24 25 26 |
# File 'lib/namira/middleware/redirector.rb', line 18 def call(env) @app.call(env) rescue Errors::HTTPError => e if redirect?(e, env) handle_redirect(env, e) else raise e end end |