From dddac0d17bc796c7561b38cc6ee75b706ce81d90 Mon Sep 17 00:00:00 2001 From: Adedayo Omitayo Date: Mon, 31 Dec 2012 16:45:58 +0100 Subject: [PATCH] Added support for express3.x route handler queue --- index.js | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/index.js b/index.js index e5fd172..8957ba8 100644 --- a/index.js +++ b/index.js @@ -149,8 +149,8 @@ Resource.prototype.map = function(method, path, fn){ , fn: fn }; - // apply the route - this.app[method](route, function(req, res, next){ + + var contentNegotiate = function(req, res, next){ req.format = req.params.format || req.format || self.format; if (req.format) res.type(req.format); if ('object' == typeof fn) { @@ -162,7 +162,11 @@ Resource.prototype.map = function(method, path, fn){ } else { fn(req, res, next); } - }); + }; + + var routeHandler = Array.isArray(fn) || typeof fn === 'function'? fn : contentNegotiate; + // apply the route + this.app[method](route, routeHandler); return this; };