diff options
author | Joshua Peek <josh@joshpeek.com> | 2010-01-04 19:38:56 -0600 |
---|---|---|
committer | Joshua Peek <josh@joshpeek.com> | 2010-01-04 19:40:16 -0600 |
commit | 76b5f18feba3f1d0507b4c4ec34d11d9bb1c493c (patch) | |
tree | 0b759bfcb59817b9a511b07f0be4743863ab8b9e /railties/lib/rails | |
parent | 56b28ec8d6b226414fb240d4d4f6f1bd25292dc9 (diff) | |
download | rails-76b5f18feba3f1d0507b4c4ec34d11d9bb1c493c.tar.gz rails-76b5f18feba3f1d0507b4c4ec34d11d9bb1c493c.tar.bz2 rails-76b5f18feba3f1d0507b4c4ec34d11d9bb1c493c.zip |
Default middleware stack needs to be available at configuration time
Diffstat (limited to 'railties/lib/rails')
-rw-r--r-- | railties/lib/rails/configuration.rb | 20 |
1 files changed, 17 insertions, 3 deletions
diff --git a/railties/lib/rails/configuration.rb b/railties/lib/rails/configuration.rb index 7c1d549c9a..7929cba2fe 100644 --- a/railties/lib/rails/configuration.rb +++ b/railties/lib/rails/configuration.rb @@ -4,11 +4,25 @@ module Rails # Temporarily separate the plugin configuration class from the main # configuration class while this bit is being cleaned up. class Railtie::Configuration - def self.default @default ||= new end + def self.default_middleware_stack + ActionDispatch::MiddlewareStack.new.tap do |middleware| + middleware.use('ActionDispatch::Static', lambda { Rails.public_path }, :if => lambda { Rails.application.config.serve_static_assets }) + middleware.use('::Rack::Lock', :if => lambda { !ActionController::Base.allow_concurrency }) + middleware.use('::Rack::Runtime') + middleware.use('ActionDispatch::ShowExceptions', lambda { ActionController::Base.consider_all_requests_local }) + middleware.use('ActionDispatch::Callbacks', lambda { ActionController::Dispatcher.prepare_each_request }) + middleware.use(lambda { ActionController::Base.session_store }, lambda { ActionController::Base.session_options }) + middleware.use('ActionDispatch::ParamsParser') + middleware.use('::Rack::MethodOverride') + middleware.use('::Rack::Head') + middleware.use('ActionDispatch::StringCoercion') + end + end + attr_reader :middleware def initialize(base = nil) @@ -17,7 +31,7 @@ module Rails @middleware = base.middleware.dup else @options = Hash.new { |h,k| h[k] = ActiveSupport::OrderedOptions.new } - @middleware = ActionDispatch::MiddlewareStack.new + @middleware = self.class.default_middleware_stack end end @@ -230,7 +244,7 @@ module Rails def log_level @log_level ||= RAILS_ENV == 'production' ? :info : :debug end - + def time_zone @time_zone ||= "UTC" end |