3
我有中间件说:如何知道从哪个路径调用中间件?
var app = express();
var someMiddleware = function(req, res, next){
//here i want to know for which route it's executing for eg. if i hit my app with xyz.com/xyz/123 it will hit route defined below which i want to identify in this middleware execution
};
app.get('xyz/:parameter', someMiddleware,function(req, res, next){
//some action on request
});
所以,这里在执行我要检查路线中间件正好被要求对那些。
'console.log(req.url)'? –
因此,要求req可以是test/111或test/112,其中111和112是req参数。并且两者都是相同的test /:testId路由。 –