Skip to content

Instantly share code, notes, and snippets.

Created December 15, 2012 06:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anonymous/4291781 to your computer and use it in GitHub Desktop.
Save anonymous/4291781 to your computer and use it in GitHub Desktop.
Rack Cascade
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