Explorar o código

新增new context

dcsunny %!s(int64=4) %!d(string=hai) anos
pai
achega
981a6e09d8
Modificáronse 1 ficheiros con 13 adicións e 0 borrados
  1. 13 0
      common/context.go

+ 13 - 0
common/context.go

@@ -0,0 +1,13 @@
+package common
+
+import (
+	"context"
+
+	context2 "git.ikuban.com/server/kratos-utils/http/context"
+)
+
+func NewContext(userID int64) context.Context {
+	ctx := context.Background()
+	ctx = context2.AppendToContext(ctx, "user_id", userID)
+	return ctx
+}