Created
December 15, 2012 06:39
-
-
Save anonymous/4291781 to your computer and use it in GitHub Desktop.
Rack Cascade
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'rubygems' | |
require 'thin' | |
require 'rack' | |
success = Rack::URLMap.new("/" => lambda { |env| [200, {"Content-Type" => "text/html"}, ["foo"]] }) | |
success_app = Rack::Builder.new do | |
use Rack::Lock | |
run success | |
end | |
error = Rack::URLMap.new("/" => lambda { |env| [404, {"Content-Type" => "text/html"}, ["foo"]] }) | |
error_app = Rack::Builder.new do | |
use Rack::Lock | |
run error | |
end | |
Rack::Handler::Thin.run Rack::Cascade.new([ | |
error_app, | |
success_app | |
]) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment