camping/camping — Issue #45: Make Camping and Rack-Flash good buddies
Author: igravious
Created: 2011-10-21 13:38:07+00:00
State: open

We do some rack.session because we want a pretty @state
This does not work with middleware like Rack-Flash
Rack-Flash already kinda works for vanilla Rack apps (they monkey patch use() and run() which is bold but ...) and it works with Sinatra so let's try to make it work with us. Then we have one less reason to have rails-envy

Offending code is in to_a()
```ruby
def to_a
@env['rack.session'] = (Hash[@state])
r = Rack::Response.new(@body, @status, @headers)
@cookies._n.each do |k, v|
r.set_cookie(k, v)
end
r.to_a
```
and
```ruby
def initialize(env, m) #:nodoc:
r = @request = Rack::Request.new(@env = env)
@root, @input, @cookies, @state,
@headers, @status, @method =
r.script_name.sub(/\/$/,''), n(r.params),
Cookies[r.cookies], H[r.session.to_hash],
{}, m =~ /r(\d+)/ ? $1.to_i : 200, m
@cookies._p = self/"/"
end
```