刚是具体路由的方法层面,也可以放到整个主路由控制器层面

This commit is contained in:
Jeremy Yin 2019-06-18 22:43:55 +08:00
parent 8ef85cd82e
commit b4306f2cbb
1 changed files with 2 additions and 1 deletions

View File

@ -5,6 +5,7 @@ import { DemoFilter } from '../../core/filters/demo.filter'
@Controller('posts') @Controller('posts')
@UseFilters(DemoFilter)
export class PostsController { export class PostsController {
constructor(private readonly demoService: DemoService) {} constructor(private readonly demoService: DemoService) {}
@ -22,7 +23,7 @@ export class PostsController {
} }
@Post() @Post()
@UseFilters(DemoFilter) // @UseFilters(DemoFilter)
store(@Body() post: CreatePostDto) { store(@Body() post: CreatePostDto) {
// throw new HttpException('没有权限!', HttpStatus.FORBIDDEN) // throw new HttpException('没有权限!', HttpStatus.FORBIDDEN)
throw new ForbiddenException('没有权限!') throw new ForbiddenException('没有权限!')