Class: Middleman::Redirects::Middleware

Inherits:
Object
  • Object
show all
Defined in:
lib/middleman/redirects.rb

Instance Method Summary collapse

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