diff options
author | José Valim <jose.valim@gmail.com> | 2010-05-29 22:29:14 +0200 |
---|---|---|
committer | Mikel Lindsaar <raasdnil@gmail.com> | 2010-06-03 23:32:10 +1000 |
commit | 2740943634fe151fb3fb87e2af7881a93f5dd6b5 (patch) | |
tree | 4916366ccf706c49f7e2082a406a2a90471dff79 /railties/lib/rails/application.rb | |
parent | 27939bd753b79c8205d1d3c1cdc7db6205642302 (diff) | |
download | rails-2740943634fe151fb3fb87e2af7881a93f5dd6b5.tar.gz rails-2740943634fe151fb3fb87e2af7881a93f5dd6b5.tar.bz2 rails-2740943634fe151fb3fb87e2af7881a93f5dd6b5.zip |
Remove the laziness from the middleware stack.
Diffstat (limited to 'railties/lib/rails/application.rb')
-rw-r--r-- | railties/lib/rails/application.rb | 28 |
1 files changed, 27 insertions, 1 deletions
diff --git a/railties/lib/rails/application.rb b/railties/lib/rails/application.rb index c588a41443..7416e94eeb 100644 --- a/railties/lib/rails/application.rb +++ b/railties/lib/rails/application.rb @@ -124,7 +124,10 @@ module Rails end def app - @app ||= config.middleware.build(routes) + @app ||= begin + config.middleware = config.middleware.merge_into(default_middleware_stack) + config.middleware.build(routes) + end end def call(env) @@ -148,6 +151,29 @@ module Rails protected + def default_middleware_stack + ActionDispatch::MiddlewareStack.new.tap do |middleware| + middleware.use ::ActionDispatch::Static, paths.public.to_a.first if config.serve_static_assets + middleware.use ::Rack::Lock if !config.allow_concurrency + middleware.use ::Rack::Runtime + middleware.use ::Rails::Rack::Logger + middleware.use ::ActionDispatch::ShowExceptions, config.consider_all_requests_local if config.action_dispatch.show_exceptions + middleware.use ::ActionDispatch::RemoteIp, config.action_dispatch.ip_spoofing_check, config.action_dispatch.trusted_proxies + middleware.use ::Rack::Sendfile, config.action_dispatch.x_sendfile_header + middleware.use ::ActionDispatch::Callbacks, !config.cache_classes + middleware.use ::ActionDispatch::Cookies + + if config.session_store + middleware.use config.session_store, config.session_options + middleware.use ::ActionDispatch::Flash + end + + middleware.use ::ActionDispatch::ParamsParser + middleware.use ::Rack::MethodOverride + middleware.use ::ActionDispatch::Head + end + end + def initialize_tasks require "rails/tasks" task :environment do |