aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/lib/action_controller/dispatcher.rb
diff options
context:
space:
mode:
authorJoshua Peek <josh@joshpeek.com>2008-12-18 13:14:09 -0600
committerJoshua Peek <josh@joshpeek.com>2008-12-18 13:14:09 -0600
commita9fde9a2abd6a6505d5fd197ad9640470d8df9be (patch)
treef115acdeed96396d52a35a875ce5270585db3bc5 /actionpack/lib/action_controller/dispatcher.rb
parent3b35366d5df8c8d8a7b216c42dd96b0cfa38fee4 (diff)
downloadrails-a9fde9a2abd6a6505d5fd197ad9640470d8df9be.tar.gz
rails-a9fde9a2abd6a6505d5fd197ad9640470d8df9be.tar.bz2
rails-a9fde9a2abd6a6505d5fd197ad9640470d8df9be.zip
Cleanup dispatch path
Diffstat (limited to 'actionpack/lib/action_controller/dispatcher.rb')
-rw-r--r--actionpack/lib/action_controller/dispatcher.rb27
1 files changed, 9 insertions, 18 deletions
diff --git a/actionpack/lib/action_controller/dispatcher.rb b/actionpack/lib/action_controller/dispatcher.rb
index 5a185eb59c..11c4f057d8 100644
--- a/actionpack/lib/action_controller/dispatcher.rb
+++ b/actionpack/lib/action_controller/dispatcher.rb
@@ -65,18 +65,23 @@ module ActionController
include ActiveSupport::Callbacks
define_callbacks :prepare_dispatch, :before_dispatch, :after_dispatch
- # DEPRECATE: Remove arguments
+ # DEPRECATE: Remove arguments, since they are only used by CGI
def initialize(output = $stdout, request = nil, response = nil)
- @output, @request, @response = output, request, response
+ @output = output
@app = @@middleware.build(lambda { |env| self.dup._call(env) })
end
def dispatch
begin
run_callbacks :before_dispatch
- handle_request
+ controller = Routing::Routes.recognize(@request)
+ controller.process(@request, @response).to_a
rescue Exception => exception
- failsafe_rescue exception
+ if controller ||= (::ApplicationController rescue Base)
+ controller.process_with_exception(@request, @response, exception).to_a
+ else
+ raise exception
+ end
ensure
run_callbacks :after_dispatch, :enumerator => :reverse_each
end
@@ -123,19 +128,5 @@ module ActionController
return if @request.key?("rack.test")
ActiveRecord::Base.clear_active_connections!
end
-
- protected
- def handle_request
- @controller = Routing::Routes.recognize(@request)
- @controller.process(@request, @response).out
- end
-
- def failsafe_rescue(exception)
- if @controller ||= (::ApplicationController rescue Base)
- @controller.process_with_exception(@request, @response, exception).out
- else
- raise exception
- end
- end
end
end