Module: Deas::TrailingSlashes::AllowHandler

Defined in:
lib/deas/trailing_slashes.rb,
lib/deas/trailing_slashes.rb

Class Method Summary collapse

Class Method Details

.run(env) ⇒ Object



61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
# File 'lib/deas/trailing_slashes.rb', line 61

def self.run(env)
  status, headers, body = yield
  if env['deas.error'].kind_of?(Deas::NotFound)
    # reset 'deas.error' state
    env['deas.error'] = nil

    # switching the trailing slash of the path info
    env['PATH_INFO'] = if env['PATH_INFO'][-1..-1] == Deas::Router::SLASH
      env['PATH_INFO'][0..-2]
    else
      env['PATH_INFO']+Deas::Router::SLASH
    end

    # retry
    yield
  else
    [status, headers, body]
  end
end