Skip to content

Commit

Permalink
Refactor away init middleware
Browse files Browse the repository at this point in the history
  • Loading branch information
dougwilson committed Jul 26, 2014
1 parent 82601d8 commit ad76ebc
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 29 deletions.
21 changes: 18 additions & 3 deletions lib/application.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ var finalhandler = require('finalhandler');
var mixin = require('utils-merge');
var Router = require('./router');
var methods = require('methods');
var middleware = require('./middleware/init');
var debug = require('debug')('express:application');
var View = require('./view');
var http = require('http');
Expand Down Expand Up @@ -98,8 +97,6 @@ app.lazyrouter = function() {
caseSensitive: this.enabled('case sensitive routing'),
strict: this.enabled('strict routing')
});

this._router.use(middleware.init(this));
}
};

Expand Down Expand Up @@ -128,6 +125,24 @@ app.handle = function(req, res, done) {
return;
}

// set powered by header
if (this.enabled('x-powered-by')) {
res.setHeader('X-Powered-By', 'Express');
}

// set circular references
req.res = res;
res.req = req;

// alter the prototypes
req.__proto__ = this.request;
res.__proto__ = this.response;

// setup locals
if (!res.locals) {
res.locals = Object.create(null);
}

router.handle(req, res, done);
};

Expand Down
26 changes: 0 additions & 26 deletions lib/middleware/init.js

This file was deleted.

0 comments on commit ad76ebc

Please sign in to comment.