raspberryGPIOhtmlserver/node_modules/express/lib/middleware.js
node_modules/express/lib/middleware.jsRaw
1
2/**
3 * Module dependencies.
4 */
5
6var utils = require('./utils');
7
8/**
9 * Initialization middleware, exposing the
10 * request and response to eachother, as well
11 * as defaulting the X-Powered-By header field.
12 *
13 * @param {Function} app
14 * @return {Function}
15 * @api private
16 */
17
18exports.init = function(app){
19 return function expressInit(req, res, next){
20 req.app = res.app = app;
21 if (app.enabled('x-powered-by')) res.setHeader('X-Powered-By', 'Express');
22 req.res = res;
23 res.req = req;
24 req.next = next;
25
26 req.__proto__ = app.request;
27 res.__proto__ = app.response;
28
29 res.locals = res.locals || utils.locals(res);
30
31 next();
32 }
33};