[TOC]
# **1. 启用注解**
`@GoEnableToken`
`@GoHeader`
`@GoToken`
# **2. 配置文件**
```
FastBoot:
token:
header: token # 令牌键,默认token
include-paths: # 包含路径
- /api/**
exclude-paths: # 排除路径
- /js/**
```
# **3. 注意事项**
> 如需使用,需先开启@GoEnableToken,参数前加上@GoToken注解即可,
同时可以通过@GoHeader获取请求header信息
## **3.1 生成令牌**
```
Map<String, Object> claims = Maps.newHashMap();
claims.put(TokenCfg.USERID, member.getId());
String token = JwtHelper.create("FastBoot", "api", claims, JwtHelper.JWT_EXPIRE_D_7);
```
```
eyJ1c2VyIjoieHh4IiwiYWxnIjoiSFMyNTYifQ.eyJqdGkiOiI1ODU4ZTM2MmU1ZTQ0ZTM4OGFjNzBmOGEzMDQ4OTA1NCIsInN1YiI6ImZhc3Rib290IiwiaXNzIjoiZmFzdGJvb3QiLCJhdWQiOiJhcGkiLCJpYXQiOjE2MjQ3MzE1ODIsImV4cCI6MTYyNDgxNzk4MiwidWlkIjoiMTIzIn0.wlWwq8RG8Z7GKcJ1hgRcwgO7gRTgAHMfbR-jPf5nquM
```
# **4. 示例说明**
```
@RestController
@RequestMapping("/token")
public class TokenController extends BaseController {
@RequestMapping(value = "header")
public Result header(String name, @GoToken String uid, @GoHeader HeaderParams p1) {
return R.succ(Lists.newArrayList(name, uid, p1));
}
}
```
```
[FastBoot][ INFO][06-27 02:21:37]-->[http-nio-auto-1-exec-1:19205][loggerAroundAspect(LoggerAspect.java:109)] | - | request header | ["fasotboot","123",{"uid":"123"}]
[FastBoot][ INFO][06-27 02:21:37]-->[http-nio-auto-1-exec-1:19223][loggerAroundAspect(LoggerAspect.java:120)] | - | response time 9ms | header | {"code":0,"msg":"操作成功","data":["fasotboot","123",{"uid":"123"}],"status":true}
```
## **4.1 不传返回**
```
{
"code": 5000,
"msg": "凭据错误:未登录",
"success": false
}
```
## **4.2 传错返回**
```
{
"code": 5000,
"msg": "凭据错误",
"success": false
}
```
## **4.3 过期返回**
```
{
"code": 5000,
"msg": "凭据过期",
"success": false
}
```