Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the difference between metadata.FromOutgoingContext and metadata.FromIncomingContext?

Tags:

go

grpc

If you are in a middle-ware that both receives the context and maybe append some data to context to send it to the next interceptor, then which of the two methods i.e. metadata.FromOutgoingContext and metadata.FromIncomingContext shall be called?

like image 527
Javad M. Amiri Avatar asked Jul 16 '19 15:07

Javad M. Amiri


1 Answers

If you are writing that middle-ware in the server, then you are receiving that metadata in the incoming request.

You should then use metadata.FromIncomingContext to get the metadata at that point.

The metadata in the "outgoing context" is the one generated by the client when sending an outgoing request to the server.

See here for examples of both:

https://github.com/grpc/grpc-go/blob/master/Documentation/grpc-metadata.md

like image 165
eugenioy Avatar answered Nov 04 '22 15:11

eugenioy