14

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?

Javad M. Amiri
  • 594
  • 5
  • 20

1 Answers1

11

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

eugenioy
  • 11,825
  • 28
  • 35