mirror of https://gitee.com/bigwinds/arangodb
Converted req.path into a method (no longer useless).
This commit is contained in:
parent
bd09144970
commit
de97cfa5fb
|
@ -970,7 +970,7 @@ function flattenRouting (routes, path, rexpr, urlParameters, depth, prefix) {
|
||||||
|
|
||||||
result = result.concat(flattenRouting(
|
result = result.concat(flattenRouting(
|
||||||
parameter.match,
|
parameter.match,
|
||||||
path + "/<parameters>",
|
path + "/:" + parameter.parameter,
|
||||||
cur,
|
cur,
|
||||||
newUrlParameters,
|
newUrlParameters,
|
||||||
depth + 1,
|
depth + 1,
|
||||||
|
@ -1009,7 +1009,7 @@ function flattenRouting (routes, path, rexpr, urlParameters, depth, prefix) {
|
||||||
if (routes.hasOwnProperty('prefix')) {
|
if (routes.hasOwnProperty('prefix')) {
|
||||||
result = result.concat(flattenRouting(
|
result = result.concat(flattenRouting(
|
||||||
routes.prefix,
|
routes.prefix,
|
||||||
path + "/...",
|
path + "/*",
|
||||||
rexpr + "(/[^/]+)*/?",
|
rexpr + "(/[^/]+)*/?",
|
||||||
urlParameters._shallowCopy,
|
urlParameters._shallowCopy,
|
||||||
depth + 1,
|
depth + 1,
|
||||||
|
@ -1292,6 +1292,22 @@ function routeRequest (req, res, routes) {
|
||||||
req.urlParameters = {};
|
req.urlParameters = {};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (req.path) {
|
||||||
|
var path = req.path;
|
||||||
|
req.path = function (params, suffix) {
|
||||||
|
var p = path;
|
||||||
|
params = params || req.urlParameters;
|
||||||
|
Object.keys(params).forEach(function (key) {
|
||||||
|
p = p.replace(new RegExp(':' + key, 'g'), params[key]);
|
||||||
|
});
|
||||||
|
suffix = suffix || req.suffix;
|
||||||
|
if (Array.isArray(suffix)) {
|
||||||
|
suffix = suffix.join('/');
|
||||||
|
}
|
||||||
|
return p.replace(/\*$/, suffix || '');
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
var func = action.route.callback.controller;
|
var func = action.route.callback.controller;
|
||||||
|
|
||||||
if (func === null || typeof func !== 'function') {
|
if (func === null || typeof func !== 'function') {
|
||||||
|
|
Loading…
Reference in New Issue