javascript - Node.js custom render building -
i'm building api in node.js express, , extend basic res.send of external route files before response sent, pre-format response , append in additional data. how possible? in advance!
that's purpose of middleware. see http://expressjs.com/api.html#middleware
for example, these lines activate csrf middleware , make csrf token available templates , generate csrf cookie used angularjs:
.use(express.csrf()) .use(function (req, res, next) { res.cookie('xsrf-token', req.session._csrf); res.locals.csrftoken = req.session._csrf; next(); })
Comments
Post a Comment