diff --git a/js/server/modules/org/arangodb/actions.js b/js/server/modules/org/arangodb/actions.js index 86f901543b..fd56096e2b 100644 --- a/js/server/modules/org/arangodb/actions.js +++ b/js/server/modules/org/arangodb/actions.js @@ -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 diff --git a/js/server/modules/org/arangodb/foxx.js b/js/server/modules/org/arangodb/foxx.js index 6132e5d127..06dd11eb09 100644 --- a/js/server/modules/org/arangodb/foxx.js +++ b/js/server/modules/org/arangodb/foxx.js @@ -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); }