mirror of
https://github.com/linka-cloud/grpc.git
synced 2024-12-22 17:00:45 +00:00
fix metadata client interceptors
Signed-off-by: Adphi <philippe.adrien.nousse@gmail.com>
This commit is contained in:
parent
97ced73270
commit
08a67bf162
@ -37,18 +37,14 @@ func (i mdInterceptors) StreamServerInterceptor() grpc.StreamServerInterceptor {
|
||||
|
||||
func (i mdInterceptors) UnaryClientInterceptor() grpc.UnaryClientInterceptor {
|
||||
return func(ctx context.Context, method string, req, reply interface{}, cc *grpc.ClientConn, invoker grpc.UnaryInvoker, opts ...grpc.CallOption) error {
|
||||
if err := grpc.SetHeader(ctx, metadata.Pairs(i.pairs...)); err != nil {
|
||||
return err
|
||||
}
|
||||
ctx = metadata.NewOutgoingContext(ctx, metadata.Pairs(i.pairs...))
|
||||
return invoker(ctx, method, req, reply, cc, opts...)
|
||||
}
|
||||
}
|
||||
|
||||
func (i mdInterceptors) StreamClientInterceptor() grpc.StreamClientInterceptor {
|
||||
return func(ctx context.Context, desc *grpc.StreamDesc, cc *grpc.ClientConn, method string, streamer grpc.Streamer, opts ...grpc.CallOption) (grpc.ClientStream, error) {
|
||||
if err := grpc.SetHeader(ctx, metadata.Pairs(i.pairs...)); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
ctx = metadata.NewOutgoingContext(ctx, metadata.Pairs(i.pairs...))
|
||||
return streamer(ctx, desc, cc, method, opts...)
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user