有没有办法检查 express 应用程序调用堆栈中的下一个中间件函数是什么?
我试图通过比较next函数和我肯定知道接下来会被调用的函数的引用来进行检查。
public static async requestMapper(request: Request, response: Response, next: Function){
console.log(next == ExampleController.exampleHandler)
next();
}
尽管我确实知道接下来会调用 ExampleController.exampleHandler,但此代码段的输出是 false
从 express documentation 无法访问下一个中间件。中间件函数可以执行以下任务:
如果你试图了解下一个中间件,我认为你的方法不好。