Last change
on this file since 484 was
484,
checked in by hendrikvanantwerpen, 11 years ago
|
Commit node_modules, to make checkouts and builds more deterministic.
|
File size:
662 bytes
|
Line | |
---|
1 | |
---|
2 | /** |
---|
3 | * Module dependencies. |
---|
4 | */ |
---|
5 | |
---|
6 | var 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 | |
---|
18 | exports.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 | }; |
---|
Note: See
TracBrowser
for help on using the repository browser.