diff --git a/app/fns.go b/app/fns.go index aa62e32..5888c08 100644 --- a/app/fns.go +++ b/app/fns.go @@ -101,6 +101,11 @@ var ErrInvalidToken = &Error{ Message: "错误令牌", } +func UserTokenFromContext(ctx context.Context) (*UserToken, bool) { + ut, ok := ctx.Value("USER_TOKEN").(*UserToken) + return ut, ok +} + func CheckAuthToken(next http.Handler) http.Handler { return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { token, _, _ := jwtauth.FromContext(r.Context())