Created
October 9, 2009 21:26
-
-
Save nakajima/206376 to your computer and use it in GitHub Desktop.
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 'rack' | |
require 'rack-flash' | |
get = proc { |env| | |
[200, {}, | |
env['x-rack.flash'].notice || 'No flash set. Try going to /set' | |
] | |
} | |
set = proc { |env| | |
env['x-rack.flash'].notice = 'Hey, the flash was set!' | |
[302, {'Location' => '/'}, | |
'You are being redirected.' | |
] | |
} | |
builder = Rack::Builder.new do | |
use Rack::Session::Cookie | |
use Rack::Flash, :accessorize => [:notice] | |
map('/set') { run set } | |
map('/') { run get } | |
end | |
Rack::Handler::Mongrel.run builder, :Port => 9292 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment