mirror of
https://github.com/v2fly/v2ray-core.git
synced 2026-06-19 01:09:55 -04:00
refactor
This commit is contained in:
@@ -10,10 +10,12 @@ const (
|
||||
userKey key = iota
|
||||
)
|
||||
|
||||
// ContextWithUser returns a context combined with an User.
|
||||
func ContextWithUser(ctx context.Context, user *User) context.Context {
|
||||
return context.WithValue(ctx, userKey, user)
|
||||
}
|
||||
|
||||
// UserFromContext extracts an User from the given context, if any.
|
||||
func UserFromContext(ctx context.Context) *User {
|
||||
v := ctx.Value(userKey)
|
||||
if v == nil {
|
||||
|
||||
Reference in New Issue
Block a user