Skip to content

Commit

Permalink
AD::Cascade that supports X-Cascade
Browse files Browse the repository at this point in the history
  • Loading branch information
josh committed Dec 26, 2009
1 parent 673fa7f commit feb7382
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 0 deletions.
1 change: 1 addition & 0 deletions actionpack/lib/action_dispatch.rb
Expand Up @@ -41,6 +41,7 @@ module ActionDispatch


autoload_under 'middleware' do autoload_under 'middleware' do
autoload :Callbacks autoload :Callbacks
autoload :Cascade
autoload :ParamsParser autoload :ParamsParser
autoload :Rescue autoload :Rescue
autoload :ShowExceptions autoload :ShowExceptions
Expand Down
29 changes: 29 additions & 0 deletions actionpack/lib/action_dispatch/middleware/cascade.rb
@@ -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

0 comments on commit feb7382

Please sign in to comment.