wfz 3 năm trước cách đây
mục cha
commit
a2dd9c6a96
1 tập tin đã thay đổi với 7 bổ sung7 xóa
  1. 7 7
      internal/middleware/middleware.go

+ 7 - 7
internal/middleware/middleware.go

@@ -12,7 +12,7 @@ import (
 
 //GetUserID 为userid
 func GetUserID(c context.Context) string {
-	userID := c.Value("userId")
+	userID := c.Value("user_id")
 	if _, ok := userID.(string); ok {
 		return userID.(string)
 	}
@@ -20,7 +20,7 @@ func GetUserID(c context.Context) string {
 }
 
 func GetAccountID(c context.Context) string {
-	accountID := c.Value("accountId")
+	accountID := c.Value("account_id")
 	if _, ok := accountID.(string); ok {
 		return accountID.(string)
 	}
@@ -28,7 +28,7 @@ func GetAccountID(c context.Context) string {
 }
 
 func GetAuthToken(c context.Context) string {
-	token := c.Value("token")
+	token := c.Value("auth_token")
 	if _, ok := token.(string); ok {
 		return token.(string)
 	}
@@ -36,7 +36,7 @@ func GetAuthToken(c context.Context) string {
 }
 
 func GetJwtClaims(c context.Context) json.RawMessage {
-	claim := c.Value("claim")
+	claim := c.Value("jwt_claims")
 	if _, ok := claim.(json.RawMessage); ok {
 		return claim.(json.RawMessage)
 	}
@@ -60,12 +60,12 @@ func GetPageOffset(c context.Context) (string, int64) {
 func GrpcValue(handler middleware.Handler) middleware.Handler {
 	return func(ctx context.Context, req interface{}) (reply interface{}, err error) {
 		if md, ok := metadata.FromIncomingContext(ctx); ok {
-			userID := md.Get("userId")
+			userID := md.Get("user_id")
 			if len(userID) > 0 {
 				ctx = context2.AppendToContext(ctx, "userId", userID[0])
 			}
 
-			accountID := md.Get("accountId")
+			accountID := md.Get("account_id")
 			if len(accountID) > 0 {
 				ctx = context2.AppendToContext(ctx, "accountId", accountID[0])
 			}
@@ -104,7 +104,7 @@ func GrpcValue(handler middleware.Handler) middleware.Handler {
 			if len(uri) > 0 {
 				ctx = context2.AppendToContext(ctx, "uri", uri[0])
 			}
-			userAgent := md.Get("userAgent")
+			userAgent := md.Get("user_agent")
 			if len(uri) > 0 {
 				ctx = context2.AppendToContext(ctx, "userAgent", userAgent[0])
 			}