Skip to content

Commit b927773

Browse files
authored
docs: Update guard.md (#4394)
1 parent 66bed06 commit b927773

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

site/docs/guard.md

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -206,9 +206,10 @@ export function Role(roleName: string | string[]): MethodDecorator {
206206
编写一个守卫,用于角色鉴权。
207207

208208
```typescript
209-
import { IMiddleware, Guard, IGuard, getPropertyMetadata } from '@midwayjs/core';
209+
// src/guard/auth.guard.ts
210+
import { Guard, IGuard, getPropertyMetadata } from '@midwayjs/core';
210211
import { Context } from '@midwayjs/koa';
211-
import { ROLE_META_KEY } from '../decorator/role.decorator.ts';
212+
import { ROLE_META_KEY } from '../decorator/role.decorator';
212213

213214
@Guard()
214215
export class AuthGuard implements IGuard<Context> {
@@ -229,9 +230,10 @@ export class AuthGuard implements IGuard<Context> {
229230
在路由上使用该守卫。
230231

231232
```typescript
232-
import { Controller, Get } from '@midwayjs/core';
233+
import { Controller, Get, UseGuard } from '@midwayjs/core';
233234
import { ReportMiddleware } from '../middleware/report.middlweare';
234235
import { AuthGuard } from '../guard/auth.guard';
236+
import { Role } from '../decorator/role.decorator';
235237

236238
@UseGuard(AuthGuard)
237239
@Controller('/user')

0 commit comments

Comments
 (0)