Skip to content

Commit

Permalink
improve req population for callbacks mode
Browse files Browse the repository at this point in the history
  • Loading branch information
jkyberneees committed Jun 21, 2019
1 parent 21cea06 commit 82ac809
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,12 +45,10 @@ module.exports = (options = {}) => {
// registering 'request' handler
if (prp) {
server.on('request', (req, res) => {
req.originalUrl = req.url
setImmediate(() => app.handle(req, res))
})
} else {
server.on('request', (req, res) => {
req.originalUrl = req.url
app.handle(req, res)
})
}
Expand Down Expand Up @@ -170,7 +168,10 @@ module.exports = (options = {}) => {
* @param {Object} res Response object
*/
handle: (req, res) => {
// request object population
req.originalUrl = req.url
res.send = exts.response.send(options, req, res)

if (middlewares.length > 0) {
// call route middlewares and route handler
next([
Expand Down

0 comments on commit 82ac809

Please sign in to comment.