Permalink
Browse files

Move default middleware stack to middlewares.rb

  • Loading branch information...
1 parent aa002c0 commit 0b22a96b7aa39cb7244d7cee23f3d03b6117b447 @josh josh committed Dec 22, 2008
Showing with 21 additions and 17 deletions.
  1. +2 −17 actionpack/lib/action_controller/dispatcher.rb
  2. +19 −0 actionpack/lib/action_controller/middlewares.rb
View
19 actionpack/lib/action_controller/dispatcher.rb
@@ -44,23 +44,8 @@ def to_prepare(identifier = nil, &block)
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
View
19 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

0 comments on commit 0b22a96

Please sign in to comment.