Skip to content

Commit

Permalink
Merge pull request #101 from nymag/params
Browse files Browse the repository at this point in the history
pass through params in state.locals
  • Loading branch information
nelsonpecora committed Jul 12, 2015
2 parents 9bfc578 + 71f80af commit a36d6bc
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions lib/composer.js
Original file line number Diff line number Diff line change
Expand Up @@ -234,6 +234,16 @@ function setUriRouteHandlers(routes) {
uriRoutes = routes;
}

/**
* add params to res.locals
* @param {object} req
* @param {object} res
* @returns {object}
*/
function addParams(req, res) {
return _.assign(res.locals, req.params);
}

/**
* Run composer by translating url to a "page" by base64ing it. Errors are handled by Express.
*
Expand All @@ -247,6 +257,8 @@ function composer(req, res, next) {
var urlWithoutQuerystring = req.url.split('?').shift(),
pageReference = '/uris/' + new Buffer(req.vhost.hostname + urlWithoutQuerystring).toString('base64');

addParams(req, res);

renderUri(pageReference, res)
.then(function (html) {
res.type('html');
Expand Down

0 comments on commit a36d6bc

Please sign in to comment.