Skip to content
Myr

middleware.js

This file

Path

lib/middleware.js

37 lines · 760 bytes · JavaScript

Last changed by

Merge branch 'master' of github.com:visionmedia/expressTJ Holowaychukbefore adoptionc4e0035

History of this file

Take it

refactored init middleware into its own fileTj Holowaychukbefore adoption4c316ba

lines 1–18why, one step back
1
2/*!3 * Express - middleware - init4 * Copyright(c) 2010-2011 TJ Holowaychuk <tj@vision-media.ca>5 * MIT Licensed6 */78/**9 * Initialization middleware, exposing the10 * 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){

Merge branch 'master' of github.com:visionmedia/expressTJ Holowaychukbefore adoptionc4e0035

line 19why, one step back
19 return function expressInit(req, res, next){

refactored init middleware into its own fileTj Holowaychukbefore adoption4c316ba

lines 20–37why, one step back
20 var charset;
21 res.setHeader('X-Powered-By', 'Express');22 req.app = res.app = app;23 req.res = res;24 res.req = req;25 req.next = next;2627 req.__proto__ = app.request;28 res.__proto__ = app.response;2930 res.locals = function(obj){31 for (var key in obj) res.locals[key] = obj[key];32 return res;33 };3435 next();36 }37};