diff options
Diffstat (limited to 'railties/lib')
-rw-r--r-- | railties/lib/rails/application.rb | 6 | ||||
-rw-r--r-- | railties/lib/rails/configuration.rb | 19 | ||||
-rw-r--r-- | railties/lib/rails/engine.rb | 8 |
3 files changed, 29 insertions, 4 deletions
diff --git a/railties/lib/rails/application.rb b/railties/lib/rails/application.rb index 8075068b3f..e3716992f5 100644 --- a/railties/lib/rails/application.rb +++ b/railties/lib/rails/application.rb @@ -514,5 +514,11 @@ module Rails end end end + + private + + def build_middleware + config.app_middleware + super + end end end diff --git a/railties/lib/rails/configuration.rb b/railties/lib/rails/configuration.rb index d99d27a756..30eafd59f2 100644 --- a/railties/lib/rails/configuration.rb +++ b/railties/lib/rails/configuration.rb @@ -33,9 +33,9 @@ module Rails # config.middleware.delete ActionDispatch::Flash # class MiddlewareStackProxy - def initialize - @operations = [] - @delete_operations = [] + def initialize(operations = [], delete_operations = []) + @operations = operations + @delete_operations = delete_operations end def insert_before(*args, &block) @@ -71,6 +71,19 @@ module Rails other end + + def +(other) # :nodoc: + MiddlewareStackProxy.new(@operations + other.operations, @delete_operations + other.delete_operations) + end + + protected + def operations + @operations + end + + def delete_operations + @delete_operations + end end class Generators #:nodoc: diff --git a/railties/lib/rails/engine.rb b/railties/lib/rails/engine.rb index 5fe96f58ab..457a50e649 100644 --- a/railties/lib/rails/engine.rb +++ b/railties/lib/rails/engine.rb @@ -508,7 +508,7 @@ module Rails def app @app || @app_build_lock.synchronize { @app ||= begin - config.middleware = config.app_middleware.merge_into(config.middleware).merge_into(default_middleware_stack) + config.middleware = build_middleware.merge_into(default_middleware_stack) config.middleware.build(endpoint) end } @@ -693,5 +693,11 @@ module Rails def _all_load_paths #:nodoc: @_all_load_paths ||= (config.paths.load_paths + _all_autoload_paths).uniq end + + private + + def build_middleware + config.middleware + end end end |