diff --git a/lib/server.js b/lib/server.js index 8f6a715d8..597753eea 100644 --- a/lib/server.js +++ b/lib/server.js @@ -576,7 +576,9 @@ Server.prototype._handle = function _handle(req, res) { self._route(req, res, function (route, context) { req.context = req.params = context; req.route = route.spec; - var chain = self.routes[route]; + + var r = route ? route.name : null; + var chain = self.routes[r]; self._run(req, res, route, chain, function done(e) { self.emit('after', req, res, route, e); @@ -628,7 +630,7 @@ Server.prototype._route = function _route(req, res, name, cb) { err = new ResourceNotFoundError(req.path()); emitRouteError(self, res, res, err); } else { - cb(r, ctx); + cb(route, ctx); } }); };