| 82 | // 测试规则 |
| 83 | @Post('/test') |
| 84 | public async test(@Ctx() ctx: Context) { |
| 85 | const { |
| 86 | request: { body }, |
| 87 | } = ctx; |
| 88 | const { match, url, targetTpl } = body as IRuleTest; |
| 89 | |
| 90 | if (match && (url.indexOf(match) >= 0 || new RegExp(match).test(url))) { |
| 91 | const targetRlt = this.profileService.calcPath(url, match, targetTpl); |
| 92 | // 测试规则 |
| 93 | return { |
| 94 | matchRlt: 'url匹配通过', |
| 95 | targetRlt, |
| 96 | }; |
| 97 | } |
| 98 | |
| 99 | return { |
| 100 | matchRlt: '不匹配', |
| 101 | targetRlt: '', |
| 102 | }; |
| 103 | } |
| 104 | |
| 105 | @Post('/import') |
| 106 | public async import(@Ctx() ctx: Context) { |