我有一个使用nestjs
和MiddlewareConsumer
的应用程序。
我想知道是否有一种方法可以基于标头值跳过中间件?
我查看了文档,发现只能使用路径或方法(就像我现在所做的那样),但是也许我缺少了什么?
我的代码示例:
export class Authorizationmodule implements nestModule {
configure(consumer: MiddlewareConsumer): void {
consumer.apply(DiscriminatorValidator).with(common.USERS).forRoutes(
{path: RELATIVE_RESOURCE_PATH,method: RequestMethod.POST},{path: RELATIVE_RESOURCE_PATH,method: RequestMethod.PUT});
consumer.apply(validate).forRoutes(AuthorizationController);
consumer.apply(HeadersValidator).with().forRoutes(AuthorizationController);
consumer.apply(ContextAndHeadersMiddleware).forRoutes(AuthorizationController);
}
}