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

View File

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