Skip to content
Myr

middleware.js

This file

Path

lib/middleware.js

33 lines · 663 bytes · JavaScript

Last changed by

add "x-powered-by" settingTJ Holowaychukbefore adoption5ac631a

History of this file

Take it

The walk stopped after 200 commits: lines older than 2c14d0c point at it.

clean up weird whitespace in error-pages acceptance testsTJ Holowaychukbefore adoption2c14d0c

lines 1–2why, one step back
1
2/**

Added res.locals.use(). Closes #1120TJ Holowaychukbefore adoptiondd33ef2

lines 3–8why, one step back
3 * Module dependencies.
4 */56var utils = require('./utils');78/**

clean up weird whitespace in error-pages acceptance testsTJ Holowaychukbefore adoption2c14d0c

lines 9–20why, one step back
9 * Initialization middleware, exposing the
10 * request and response to eachother, as well11 * as defaulting the X-Powered-By header field.12 *13 * @param {Function} app14 * @return {Function}15 * @api private16 */1718exports.init = function(app){19 return function expressInit(req, res, next){20 req.app = res.app = app;

add "x-powered-by" settingTJ Holowaychukbefore adoption5ac631a

line 21why, one step back
21 if (app.settings['x-powered-by']) res.setHeader('X-Powered-By', 'Express');

clean up weird whitespace in error-pages acceptance testsTJ Holowaychukbefore adoption2c14d0c

lines 22–28why, one step back
22 req.res = res;
23 res.req = req;24 req.next = next;2526 req.__proto__ = app.request;27 res.__proto__ = app.response;28

change res.sendfile() to use send() moduleTJ Holowaychukbefore adoptionab61837

line 29why, one step back
29 res.locals = res.locals || utils.locals(res);

clean up weird whitespace in error-pages acceptance testsTJ Holowaychukbefore adoption2c14d0c

lines 30–33why, one step back
30
31 next();32 }33};