From 5023b904e2f055ba4a529c5e1d13e0d291d8ab7a Mon Sep 17 00:00:00 2001 From: ap <951984189@qq.com> Date: Tue, 29 Mar 2022 16:12:00 +0800 Subject: [PATCH] urltag --- src/modules/demo/middleware/demo.ts | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/modules/demo/middleware/demo.ts b/src/modules/demo/middleware/demo.ts index 564c9fe..a19ec9c 100644 --- a/src/modules/demo/middleware/demo.ts +++ b/src/modules/demo/middleware/demo.ts @@ -1,11 +1,19 @@ +import { CoolUrlTagData, TagTypes } from '@cool-midway/core'; import { IMiddleware } from '@midwayjs/core'; -import { Middleware } from '@midwayjs/decorator'; +import { Inject, Middleware } from '@midwayjs/decorator'; import { NextFunction, Context } from '@midwayjs/koa'; @Middleware() export class DemoMiddleware implements IMiddleware { + @Inject() + tag: CoolUrlTagData; + resolve() { return async (ctx: Context, next: NextFunction) => { + const urls = this.tag.byKey(TagTypes.IGNORE_TOKEN); + + console.log('忽略token的URL数组', urls); + // 控制器前执行的逻辑 const startTime = Date.now(); // 执行下一个 Web 中间件,最后执行到控制器