Ah, thanks.  

I thought that the order of calling 'use' would explicitly describe the order. 
This was my main problem - since Camping's doing a bit of a hack to neatly slot 
the middleware in without people needing a rackup file or whatever, it's a bit 
unclear on how to get stuff in the right order.

I ended up just using Rack::Session::Cookie in my rackup file, and removing 
'include Camping::Session' from my Camping app.  


On Monday, 2 January 2012 at 10:20 PM, Jenna Fox wrote:

> If you look in to the Rack docs, you'll find more info on how to chain 
> middleware together. Camping provides some friendly shortcuts to that, but 
> 'including a module' is not how that's supposed to work, is my understanding. 
> Essentially Rack middleware work by creating an object which responds to a 
> 'call' method, and then calls the call on another thing, creating a chain of 
> 'call' method calls. Call call? Call.  
>  
> Call call call.  
>  
> But yes, if you play with that more directly, you can clearly describe which 
> objects feed in to each other, and have the session middleware at a more 
> outer layer than your own middleware. Usually this ends up looking like:
>  
> run 
> OuterMostMiddleware.new(MiddleMiddleware.new(InnerMiddleware.new(SomeCampingApp)))
>  
> Each layer wraps around the outside of the next, so the message from a web 
> request travels in left to right along this line, then the response travels 
> back right to left as each 'call' method on the middleware objects finish 
> their work and return to the next layer leftward.
>  
>  
> —
> Jenna Fox
>  
>  
> On Monday, 2 January 2012 at 10:10 PM, Daniel Bryan wrote:
>  
> > I'm trying to implement some simple middleware that will have behaviour 
> > based on session data.
> >  
> > From looking at the source for Camping::Session and Rack::Session, I 
> > thought I'd just be able to put my own middleware between Camping::Session 
> > and my app. I tried doing it the same way that Camping::Session works - by 
> > including a module in my app - but if I inspect the environment in there, 
> > it's still encrypted.
> >  
> > Has anyone else tried something like this?  
> > _______________________________________________
> > Camping-list mailing list
> > Camping-list@rubyforge.org (mailto:Camping-list@rubyforge.org)
> > http://rubyforge.org/mailman/listinfo/camping-list
> >  
> >  
> >  
>  
>  
> _______________________________________________
> Camping-list mailing list
> Camping-list@rubyforge.org (mailto:Camping-list@rubyforge.org)
> http://rubyforge.org/mailman/listinfo/camping-list
>  
>  


_______________________________________________
Camping-list mailing list
Camping-list@rubyforge.org
http://rubyforge.org/mailman/listinfo/camping-list

Reply via email to