diff options
author | Joshua Peek <josh@joshpeek.com> | 2009-12-26 13:28:06 -0600 |
---|---|---|
committer | Joshua Peek <josh@joshpeek.com> | 2009-12-26 13:28:06 -0600 |
commit | feb7382047bf5e354edd12aa89895ec4591a5614 (patch) | |
tree | 21828f6fa5857d09a761b9a5e5b8b3c6c20cdc51 /actionpack/lib | |
parent | 673fa7f06608151aa4a5e6e754894978b4000b63 (diff) | |
download | rails-feb7382047bf5e354edd12aa89895ec4591a5614.tar.gz rails-feb7382047bf5e354edd12aa89895ec4591a5614.tar.bz2 rails-feb7382047bf5e354edd12aa89895ec4591a5614.zip |
AD::Cascade that supports X-Cascade
Diffstat (limited to 'actionpack/lib')
-rw-r--r-- | actionpack/lib/action_dispatch.rb | 1 | ||||
-rw-r--r-- | actionpack/lib/action_dispatch/middleware/cascade.rb | 29 |
2 files changed, 30 insertions, 0 deletions
diff --git a/actionpack/lib/action_dispatch.rb b/actionpack/lib/action_dispatch.rb index fafcf7dc4e..0696cb017c 100644 --- a/actionpack/lib/action_dispatch.rb +++ b/actionpack/lib/action_dispatch.rb @@ -41,6 +41,7 @@ module ActionDispatch autoload_under 'middleware' do autoload :Callbacks + autoload :Cascade autoload :ParamsParser autoload :Rescue autoload :ShowExceptions diff --git a/actionpack/lib/action_dispatch/middleware/cascade.rb b/actionpack/lib/action_dispatch/middleware/cascade.rb new file mode 100644 index 0000000000..9f5c9891f0 --- /dev/null +++ b/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 |