first commit
This commit is contained in:
@@ -0,0 +1,14 @@
|
||||
package httpx
|
||||
|
||||
import "context"
|
||||
|
||||
type userIDKey struct{}
|
||||
|
||||
func WithUserID(ctx context.Context, userID int64) context.Context {
|
||||
return context.WithValue(ctx, userIDKey{}, userID)
|
||||
}
|
||||
|
||||
func UserID(ctx context.Context) (int64, bool) {
|
||||
v, ok := ctx.Value(userIDKey{}).(int64)
|
||||
return v, ok
|
||||
}
|
||||
Reference in New Issue
Block a user