1
0
Fork 0
This commit is contained in:
Thomas Richter 2013-07-27 15:14:51 +02:00
commit 5e7659ad65
2 changed files with 15 additions and 7 deletions

View File

@ -711,11 +711,13 @@ function defineRoutePart (route, subwhere, parts, pos, constraint, callback) {
defineRoutePart(route, subsub.match, parts, pos + 1, constraint, callback); defineRoutePart(route, subsub.match, parts, pos + 1, constraint, callback);
} }
else { else {
if (! subsub.match.hasOwnProperty('routes')) { var match = subsub.match;
subsub.match.routes = [];
if (! match.hasOwnProperty('routes')) {
match.routes = [];
} }
subsub.match.routes.push({ match.routes.push({
priority: route.priority || 0, priority: route.priority || 0,
route: route, route: route,
callback: callback callback: callback
@ -731,16 +733,20 @@ function defineRoutePart (route, subwhere, parts, pos, constraint, callback) {
else if (part.hasOwnProperty('prefix')) { else if (part.hasOwnProperty('prefix')) {
if (! subwhere.hasOwnProperty('prefix')) { if (! subwhere.hasOwnProperty('prefix')) {
subwhere.prefix = []; subwhere.prefix = {};
} }
var subprefix = subwhere.prefix;
if (pos + 1 < parts.length) { if (pos + 1 < parts.length) {
console.error("cannot define prefix match within url, ignoring route"); console.error("cannot define prefix match within url, ignoring route");
} }
else { else {
subprefix.push({ var subprefix = subwhere.prefix;
if (! subprefix.hasOwnProperty('routes')) {
subprefix.routes = [];
}
subprefix.routes.push({
priority: route.priority || 0, priority: route.priority || 0,
route: route, route: route,
callback: callback callback: callback

View File

@ -403,6 +403,7 @@ _.extend(Application.prototype, {
} }
this.routingInfo.middleware.push({ this.routingInfo.middleware.push({
priority: 1,
url: {match: path}, url: {match: path},
action: { action: {
callback: function (req, res, opts, next) { func(req, res, opts); next(); } callback: function (req, res, opts, next) { func(req, res, opts); next(); }
@ -436,6 +437,7 @@ _.extend(Application.prototype, {
} }
this.routingInfo.middleware.push({ this.routingInfo.middleware.push({
priority: 2,
url: {match: path}, url: {match: path},
action: { action: {
callback: function (req, res, opts, next) { next(); func(req, res, opts); } callback: function (req, res, opts, next) { next(); func(req, res, opts); }