refactor: api层尽可能屏蔽gin框架相关代码

This commit is contained in:
meilin.huang
2024-02-24 16:30:29 +08:00
parent 7e7f02b502
commit b56b0187cf
44 changed files with 639 additions and 595 deletions

View File

@@ -44,12 +44,12 @@ func PermissionHandler(rc *Ctx) error {
if permission != nil && !permission.NeedToken {
return nil
}
tokenStr := rc.GinCtx.Request.Header.Get("Authorization")
tokenStr := rc.F.GetHeader("Authorization")
// 删除前缀 Bearer, 以支持 Bearer Token
tokenStr, _ = strings.CutPrefix(tokenStr, "Bearer ")
// header不存在则从查询参数token中获取
if tokenStr == "" {
tokenStr = rc.GinCtx.Query("token")
tokenStr = rc.F.Query("token")
}
if tokenStr == "" {
return errorx.PermissionErr