Class: Middleman::Redirects::Middleware
- Inherits:
-
Object
- Object
- Middleman::Redirects::Middleware
- Defined in:
- lib/middleman/redirects.rb
Instance Method Summary collapse
- #call(env) ⇒ Object
-
#initialize(app) ⇒ Middleware
constructor
A new instance of Middleware.
Constructor Details
#initialize(app) ⇒ Middleware
20 21 22 |
# File 'lib/middleman/redirects.rb', line 20 def initialize(app) @app = app end |
Instance Method Details
#call(env) ⇒ Object
24 25 26 27 28 29 30 31 |
# File 'lib/middleman/redirects.rb', line 24 def call(env) source = env['PATH_INFO'] if destination = ::Middleman::Redirects.redirects[source] [302, {"Location" => destination}, []] else @app.call(env) end end |