Skip to content

Commit

Permalink
Use the 'request' event instead of calling the first event handler di…
Browse files Browse the repository at this point in the history
…rectly
  • Loading branch information
pixcai committed Jun 15, 2018
1 parent 8e87e27 commit 8634293
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion index.js
Expand Up @@ -94,7 +94,13 @@ proto.use = function use(route, fn) {

// wrap vanilla http.Servers
if (handle instanceof http.Server) {
handle = handle.listeners('request')[0];
var server = handle;
handle = function (req, res, next) {
server.once('request', function () {
next();
});
server.emit('request', req, res);
};
}

// strip trailing slash
Expand Down

0 comments on commit 8634293

Please sign in to comment.