mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
AD::Cascade that supports X-Cascade
This commit is contained in:
parent
673fa7f066
commit
feb7382047
2 changed files with 30 additions and 0 deletions
|
@ -41,6 +41,7 @@ module ActionDispatch
|
|||
|
||||
autoload_under 'middleware' do
|
||||
autoload :Callbacks
|
||||
autoload :Cascade
|
||||
autoload :ParamsParser
|
||||
autoload :Rescue
|
||||
autoload :ShowExceptions
|
||||
|
|
29
actionpack/lib/action_dispatch/middleware/cascade.rb
Normal file
29
actionpack/lib/action_dispatch/middleware/cascade.rb
Normal file
|
@ -0,0 +1,29 @@
|
|||
module ActionDispatch
|
||||
class Cascade
|
||||
def self.new(*apps)
|
||||
apps = apps.flatten
|
||||
|
||||
case apps.length
|
||||
when 0
|
||||
raise ArgumentError, "app is required"
|
||||
when 1
|
||||
apps.first
|
||||
else
|
||||
super(apps)
|
||||
end
|
||||
end
|
||||
|
||||
def initialize(apps)
|
||||
@apps = apps
|
||||
end
|
||||
|
||||
def call(env)
|
||||
result = nil
|
||||
@apps.each do |app|
|
||||
result = app.call(env)
|
||||
break unless result[1]["X-Cascade"] == "pass"
|
||||
end
|
||||
result
|
||||
end
|
||||
end
|
||||
end
|
Loading…
Reference in a new issue