zhangqian
2023-10-13 581cb45bb6a5cb928dfa920abf9c51652aae2da5
middleware/user.go
@@ -32,7 +32,15 @@
   }
}
var whiteList = map[string]struct{}{ //白名单地址列表
   "/api/code/getCodeList": {},
   "/api/data/getAllData":  {},
}
func CheckAuth(apiPath string, token string) bool {
   if _, ok := whiteList[apiPath]; ok {
      return true
   }
   cli := user.NewUserServiceClient(userConn)
   ctx, cancel := context.WithTimeout(context.Background(), time.Second)
   defer cancel()