1.简介
一般路径参数只能匹配一个部分,只能匹配/view/aaa,不能匹配 /view/aaa/bbb
@Public()
@Get('/view/:path')
async pdfPreview(@Param('path') path: string, @Res() res: Response) {
this.logger.log('view pdf '+path)
await this.ticketService.getPdfStream('/'+path, res);
}
2.解决
如果想要匹配后面所有路径,需要用正则表达式来指定路径参数的匹配
@Public()
@Get('/view/:path(*)')
async pdfPreview(@Param('path') path: string, @Res() res: Response) {
this.logger.log('view pdf '+path)
await this.ticketService.getPdfStream('/'+path, res);
}