Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

Already on GitHub? Sign in to your account

provide a way for middleware to populate page data #1244

drewfish opened this Issue Sep 18, 2013 · 3 comments


None yet
2 participants

drewfish commented Sep 18, 2013

Our current "page" data object is unique to each request, and is a great place to store request-specific objects/data. However, there's no way for middleware to put objects/data into it.


caridy commented Sep 18, 2013

Since the page obj is probably going to have contextualized stuff (don't know), I will suggest to allow requests to attach a page object into the request object (or potentially req.locals, which is the standard way of doing it in express 3) and then getting mojito.js to augment that object with more stuff if it exists, or just create a new object.


drewfish commented Sep 18, 2013

Well the middleware is actually just as request-specific as the page object (including contextualization).

I'm looking at line 33 of lib/output-handler.server.js, which is where the page object is created. Right after creating it we could also merge in req.page (or req.locals or whatever we want to call it).


drewfish commented Sep 18, 2013

Oh hmm... I see what you mean, mojito.js is pushing data into the page object. That's a little dirty and is being done that way because the output handler doesn't have direct access to the store. However, the output handler does have direct access to the request object, so I argue that the output handler ctor should be responsible (instead of mojito.js) for moving data from req.page[1] to the page object.

[1] ... or whatever we call it

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment