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
http://rubyforge.org/mailman/listinfo/camping-list

Reply via email to