Method: Rack::Mount::Recognition::Route#call

Defined in:
lib/rack/mount/recognition/route.rb

#call(env) ⇒ Object


14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/rack/mount/recognition/route.rb', line 14

def call(env)
  method = env[Const::REQUEST_METHOD]
  path = env[Const::PATH_INFO]

  if (@method.nil? || method == @method) && path =~ @path
    routing_args, param_matches = @defaults.dup, $~.captures
    @named_captures.each { |k, i|
      if v = param_matches[i]
        routing_args[k] = v
      end
    }
    env[Const::RACK_ROUTING_ARGS] = routing_args
    @app.call(env)
  else
    @throw
  end
end