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