Skip to content

Instantly share code, notes, and snippets.

@nakajima
Created October 9, 2009 21:26
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 nakajima/206376 to your computer and use it in GitHub Desktop.
Save nakajima/206376 to your computer and use it in GitHub Desktop.
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