module Deas::TrailingSlashes::AllowHandler

Public Class Methods

run(env) { || ... } click to toggle source
# 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