refactor a bit
This commit is contained in:
Родитель
8969f785eb
Коммит
c33d1609af
|
@ -72,11 +72,10 @@ func (s *testServer) EmptyCall(ctx context.Context, in *testpb.Empty) (*testpb.E
|
||||||
if md, ok := metadata.FromContext(ctx); ok {
|
if md, ok := metadata.FromContext(ctx); ok {
|
||||||
// For testing purpose, returns an error if there is attached metadata other than
|
// For testing purpose, returns an error if there is attached metadata other than
|
||||||
// the user agent set by the client application.
|
// the user agent set by the client application.
|
||||||
if ua, isOK := md["user-agent"]; isOK {
|
if _, ok := md["user-agent"]; !ok {
|
||||||
grpc.SendHeader(ctx, metadata.Pairs("ua", ua))
|
|
||||||
} else {
|
|
||||||
return nil, grpc.Errorf(codes.DataLoss, "got extra metadata")
|
return nil, grpc.Errorf(codes.DataLoss, "got extra metadata")
|
||||||
}
|
}
|
||||||
|
grpc.SendHeader(ctx, metadata.Pairs("ua", md["user-agent"]))
|
||||||
}
|
}
|
||||||
return new(testpb.Empty), nil
|
return new(testpb.Empty), nil
|
||||||
}
|
}
|
||||||
|
|
Загрузка…
Ссылка в новой задаче