From 0b22a96b7aa39cb7244d7cee23f3d03b6117b447 Mon Sep 17 00:00:00 2001 From: Joshua Peek Date: Mon, 22 Dec 2008 12:04:32 -0600 Subject: Move default middleware stack to middlewares.rb --- actionpack/lib/action_controller/dispatcher.rb | 19 ++----------------- actionpack/lib/action_controller/middlewares.rb | 19 +++++++++++++++++++ 2 files changed, 21 insertions(+), 17 deletions(-) create mode 100644 actionpack/lib/action_controller/middlewares.rb diff --git a/actionpack/lib/action_controller/dispatcher.rb b/actionpack/lib/action_controller/dispatcher.rb index 0cfd451c04..ae9f117e3f 100644 --- a/actionpack/lib/action_controller/dispatcher.rb +++ b/actionpack/lib/action_controller/dispatcher.rb @@ -44,23 +44,8 @@ module ActionController cattr_accessor :middleware self.middleware = MiddlewareStack.new do |middleware| - middleware.use "ActionController::Lock", :if => lambda { - !ActionController::Base.allow_concurrency - } - middleware.use "ActionController::Failsafe" - middleware.use "ActiveRecord::QueryCache" if defined?(ActiveRecord) - - ["ActionController::Session::CookieStore", - "ActionController::Session::MemCacheStore", - "ActiveRecord::SessionStore"].each do |store| - middleware.use(store, ActionController::Base.session_options, - :if => lambda { - if session_store = ActionController::Base.session_store - session_store.name == store - end - } - ) - end + middlewares = File.join(File.dirname(__FILE__), "middlewares.rb") + middleware.instance_eval(File.read(middlewares)) end include ActiveSupport::Callbacks diff --git a/actionpack/lib/action_controller/middlewares.rb b/actionpack/lib/action_controller/middlewares.rb new file mode 100644 index 0000000000..e566c6fef9 --- /dev/null +++ b/actionpack/lib/action_controller/middlewares.rb @@ -0,0 +1,19 @@ +use "ActionController::Lock", :if => lambda { + !ActionController::Base.allow_concurrency +} + +use "ActionController::Failsafe" + +use "ActiveRecord::QueryCache", :if => lambda { defined?(ActiveRecord) } + +["ActionController::Session::CookieStore", + "ActionController::Session::MemCacheStore", + "ActiveRecord::SessionStore"].each do |store| + use(store, ActionController::Base.session_options, + :if => lambda { + if session_store = ActionController::Base.session_store + session_store.name == store + end + } + ) +end -- cgit v1.2.3