| 123456789101112131415161718192021222324252627282930313233343536373839 |
- package param
- import (
- "context"
- "encoding/json"
- )
- // GetUserID 为userid
- func GetUserID(c context.Context) int64 {
- userID := c.Value("user_id")
- if _, ok := userID.(int64); ok {
- return userID.(int64)
- }
- return 0
- }
- func GetAccountID(c context.Context) int64 {
- accountID := c.Value("account_id")
- if _, ok := accountID.(int64); ok {
- return accountID.(int64)
- }
- return 0
- }
- func GetAuthToken(c context.Context) string {
- token := c.Value("token")
- if _, ok := token.(string); ok {
- return token.(string)
- }
- return ""
- }
- func GetJwtClaims(c context.Context) json.RawMessage {
- claim := c.Value("claim")
- if _, ok := claim.(json.RawMessage); ok {
- return claim.(json.RawMessage)
- }
- return []byte{}
- }
|