annotate node_modules/express/lib/middleware/init.js @ 101:52e44ee1c791 tip master

enabled all scores in autostart script
author Rob Canning <rc@kiben.net>
date Tue, 21 Apr 2015 16:20:57 +0100
parents 0c3a2942ddee
children
rev   line source
rc@73 1 /**
rc@73 2 * Initialization middleware, exposing the
rc@73 3 * request and response to eachother, as well
rc@73 4 * as defaulting the X-Powered-By header field.
rc@73 5 *
rc@73 6 * @param {Function} app
rc@73 7 * @return {Function}
rc@73 8 * @api private
rc@73 9 */
rc@73 10
rc@73 11 exports.init = function(app){
rc@73 12 return function expressInit(req, res, next){
rc@73 13 if (app.enabled('x-powered-by')) res.setHeader('X-Powered-By', 'Express');
rc@73 14 req.res = res;
rc@73 15 res.req = req;
rc@73 16 req.next = next;
rc@73 17
rc@73 18 req.__proto__ = app.request;
rc@73 19 res.__proto__ = app.response;
rc@73 20
rc@73 21 res.locals = res.locals || Object.create(null);
rc@73 22
rc@73 23 next();
rc@73 24 };
rc@73 25 };
rc@73 26