【发布时间】:2015-09-22 15:38:12
【问题描述】:
使用正则表达式时如何将“路径参数”传递给中间件。这是我需要做的一个例子:
app.use(new RegExp('/aPath/(?!notThis){variable}'), myMiddleware);
所以,在我的中间件(不应该为 '/aPath/notThis' 执行)中,我需要获取参数。
exports.myMiddleware = function (req, res, next){
console.log(req.params.variable);
}
这可能吗?
【问题讨论】: