class Deas::TrailingSlashes

Constants

HANDLERS

Public Class Methods

new(app, router) click to toggle source
# File lib/deas/trailing_slashes.rb, line 18
def initialize(app, router)
  @app    = app
  @router = router

  if !@router.trailing_slashes_set?
    val  = @router.trailing_slashes
    desc = val.nil? ? 'no' : "an invalid (`#{val.inspect}`)"
    raise ArgumentError, "TrailingSlashes middleware is in use but there is "\
                         "#{desc} trailing slashes router directive set."
  end
end

Public Instance Methods

call(env) click to toggle source

The Rack call interface. The receiver acts as a prototype and runs each request in a clone object unless the rack.run_once variable is set in the environment. Ripped from: github.com/rtomayko/rack-cache/blob/master/lib/rack/cache/context.rb

# File lib/deas/trailing_slashes.rb, line 34
def call(env)
  if env['rack.run_once']
    call! env
  else
    clone.call! env
  end
end
call!(env) click to toggle source

The real Rack call interface.

# File lib/deas/trailing_slashes.rb, line 43
def call!(env)
  HANDLERS[@router.trailing_slashes].run(env){ @app.call(env) }
end