ws
CI / changes (push) Successful in 1m29s
CI / ad (push) Successful in 0s
CI / admin (push) Successful in 0s
CI / bff (push) Successful in 29s
CI / chore (push) Successful in 0s
CI / equipment (push) Successful in 0s
CI / express (push) Successful in 0s
CI / factory (push) Successful in 0s
CI / message (push) Successful in 1s
CI / order (push) Successful in 0s
CI / payment (push) Successful in 0s
CI / product (push) Successful in 1s
CI / record (push) Successful in 0s
CI / sale (push) Successful in 20s
CI / support (push) Successful in 1s
CI / task (push) Successful in 0s
CI / user (push) Successful in 0s
CI / wecom (push) Successful in 1s
CI / changes (push) Successful in 1m29s
CI / ad (push) Successful in 0s
CI / admin (push) Successful in 0s
CI / bff (push) Successful in 29s
CI / chore (push) Successful in 0s
CI / equipment (push) Successful in 0s
CI / express (push) Successful in 0s
CI / factory (push) Successful in 0s
CI / message (push) Successful in 1s
CI / order (push) Successful in 0s
CI / payment (push) Successful in 0s
CI / product (push) Successful in 1s
CI / record (push) Successful in 0s
CI / sale (push) Successful in 20s
CI / support (push) Successful in 1s
CI / task (push) Successful in 0s
CI / user (push) Successful in 0s
CI / wecom (push) Successful in 1s
This commit is contained in:
@@ -205,3 +205,40 @@ func UserClientInterceptor(ctx context.Context, method string, req, reply any, c
|
||||
ctx = metadata.NewOutgoingContext(ctx, md)
|
||||
return invoker(ctx, method, req, reply, cc, opts...)
|
||||
}
|
||||
|
||||
// UserStreamInterceptor gRPC Stream客户端拦截器,用于ws桥接的双向流透传metadata
|
||||
func UserStreamInterceptor(ctx context.Context, desc *grpc.StreamDesc, cc *grpc.ClientConn, method string, streamer grpc.Streamer, opts ...grpc.CallOption) (grpc.ClientStream, error) {
|
||||
user := GetUserInfo(ctx)
|
||||
md := metadata.New(map[string]string{})
|
||||
|
||||
if user.Valid {
|
||||
md.Set("x-user-id", user.RawUID)
|
||||
md.Set("x-user-name", url.QueryEscape(user.Name))
|
||||
}
|
||||
|
||||
setMDIfNotEmpty(md, "x-raw-body", user.RawBody)
|
||||
setMDIfNotEmpty(md, "x-refresh", user.Refresh)
|
||||
setMDIfNotEmpty(md, "x-client-ip", user.ClientIP)
|
||||
if user.UserAgent != utils.StringEmpty {
|
||||
md.Set("x-user-agent", url.QueryEscape(user.UserAgent))
|
||||
}
|
||||
setMDIfNotEmpty(md, "x-user-type", user.Type)
|
||||
setMDIfNotEmpty(md, "x-client-code", user.ClientCode)
|
||||
setMDIfNotEmpty(md, "x-sale-id", user.SaleId)
|
||||
if user.SaleName != utils.StringEmpty {
|
||||
md.Set("x-sale-name", url.QueryEscape(user.SaleName))
|
||||
}
|
||||
setMDIfNotEmpty(md, "x-sale-mobile", user.SaleMobile)
|
||||
setMDIfNotEmpty(md, "x-sale-province", user.SaleProvince)
|
||||
setMDIfNotEmpty(md, "x-store-id", user.StoreId)
|
||||
if user.StoreName != utils.StringEmpty {
|
||||
md.Set("x-store-name", url.QueryEscape(user.StoreName))
|
||||
}
|
||||
setMDIfNotEmpty(md, "x-group-id", user.GroupId)
|
||||
if user.GroupName != utils.StringEmpty {
|
||||
md.Set("x-group-name", url.QueryEscape(user.GroupName))
|
||||
}
|
||||
|
||||
newCtx := metadata.NewOutgoingContext(ctx, md)
|
||||
return streamer(newCtx, desc, cc, method, opts...)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user