Class: Track::Application

Inherits:
Object
  • Object
show all
Defined in:
lib/track/application.rb

Instance Method Summary collapse

Instance Method Details

#call(env) ⇒ Object



6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
# File 'lib/track/application.rb', line 6

def call(env)
  req = Rack::Request.new(env)
  if route = Routes.find(req.request_method, req.path_info)
    controller = route[:class].new(env, req.params.merge(route[:matches]))
    if response = controller.run_filters(:before, route[:action])
      return response
    else
      response = controller.send(route[:action])
      controller.run_filters(:after, route[:action])
      response
    end
  else
    Track.responses[:routing_error]
  end
end