From e0cc2915f22fe74d5be9e8f51d6b73437192e0ba Mon Sep 17 00:00:00 2001 From: nsfisis Date: Thu, 6 Nov 2025 04:10:55 +0900 Subject: feat: Support multi-user --- backend/context/user.go | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 backend/context/user.go (limited to 'backend/context/user.go') diff --git a/backend/context/user.go b/backend/context/user.go new file mode 100644 index 0000000..b8987e4 --- /dev/null +++ b/backend/context/user.go @@ -0,0 +1,20 @@ +package context + +import ( + "context" +) + +type contextKey string + +const userIDContextKey contextKey = "user_id" + +// SetUserID adds the user ID to the context +func SetUserID(ctx context.Context, userID int64) context.Context { + return context.WithValue(ctx, userIDContextKey, userID) +} + +// GetUserID retrieves the user ID from the request context +func GetUserID(ctx context.Context) (int64, bool) { + userID, ok := ctx.Value(userIDContextKey).(int64) + return userID, ok +} -- cgit v1.2.3-70-g09d2