You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
21 lines
373 B
21 lines
373 B
2 years ago
|
package xuser
|
||
|
|
||
|
import "context"
|
||
|
|
||
|
func ValidateUser(token string) (int64, error) {
|
||
|
return 1, nil
|
||
|
}
|
||
|
|
||
|
type userIdKey struct {
|
||
|
}
|
||
|
|
||
|
func WithContext(ctx context.Context, userId int64) context.Context {
|
||
|
return context.WithValue(ctx, userIdKey{}, userId)
|
||
|
}
|
||
|
func FromContext(ctx context.Context) int64 {
|
||
|
if v, ok := ctx.Value(userIdKey{}).(int64); ok {
|
||
|
return v
|
||
|
}
|
||
|
return 0
|
||
|
}
|