|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Run all the middleware stuff if applicable |
|
|
// Run all the middleware stuff if applicable |
|
|
var self = this; |
|
|
var self = this; |
|
|
if (route.middleware) { |
|
|
|
|
|
|
|
|
if (route.middleware && route.middleware.length > 0) { |
|
|
var cbs = route.middleware.length; |
|
|
var cbs = route.middleware.length; |
|
|
function cb() { |
|
|
function cb() { |
|
|
if (--cbs === 0) |
|
|
if (--cbs === 0) |
|
|
route.func(req, res, self); |
|
|
route.func(req, res, self); |
|
|
|
|
|
else |
|
|
|
|
|
route.middleware.shift()(req, res, cb); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
for (var i in route.middleware) { |
|
|
|
|
|
route.middleware[i](req, res, cb); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
route.middleware.shift()(req, res, cb); |
|
|
|
|
|
|
|
|
// Just run the function if there's no middleware |
|
|
// Just run the function if there's no middleware |
|
|
} else { |
|
|
} else { |