| 123456789101112131415161718192021222324 |
- package permlib
- import "context"
- type contextKey string
- const ctxKeyUser contextKey = "permlib_user"
- type UserInfo struct {
- UserId int64
- Username string
- ProductCode string
- MemberType string
- Perms []string
- }
- func GetUser(ctx context.Context) *UserInfo {
- v, _ := ctx.Value(ctxKeyUser).(*UserInfo)
- return v
- }
- func withUser(ctx context.Context, u *UserInfo) context.Context {
- return context.WithValue(ctx, ctxKeyUser, u)
- }
|