Hi all,
i'm trying to use the context metadata aside from the pure RPC communication between my client and server.
In this code example (
https://gitlab.com/pantomath-io/demo-grpc/blob/add-auth), I have a client adding a login/password in the metadata sent to the server. This latest uses an UnaryInterceptor to extract the metadata from the context, and to process the RPC call (or block it).
Now, I'd like the server to inject metadata in the *response* to the client, and the client to read it (for instance, the server could inject a serial number in the response).
I'm quite confused on how to do that:
- do the client and server share the same context? (ie the server should set the metadata in the context it knows, and the client would read it from there?)
- are SetHeader() [1] and SetTrailer() [2] functions made just for that? If so, is it only in the case of stream (as opposed to RPC calls)?
- is there any mechanism to make this exchange systematic (like the Interceptor)?
Many thanks,
julien