1
0
mirror of https://github.com/v2fly/v2ray-core.git synced 2026-06-19 01:09:55 -04:00
This commit is contained in:
Darien Raymond
2017-08-22 15:15:09 +02:00
parent 4059a965ff
commit 1c2b6d9536
5 changed files with 55 additions and 51 deletions

View File

@@ -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 {