I finally found my 
way: https://github.com/grpc/grpc-go/blob/master/Documentation/grpc-metadata.md

So basically, grpc.SetHeader() + grpc.SendHeader() and grpc.SetTrailer() 
are totally what I was looking for. On the client side, grpc.Header() and 
grpc.Trailer() functions need to be passed to the RPC call, and their 
argument is a metadata.MD object to be filled.

Le lundi 4 décembre 2017 15:32:15 UTC+1, [email protected] a écrit :
>
> 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
>
>
> [1] https://godoc.org/google.golang.org/grpc#SetHeader
> [2] https://godoc.org/google.golang.org/grpc#SetTrailer
>

-- 
You received this message because you are subscribed to the Google Groups 
"grpc.io" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/grpc-io.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/grpc-io/6592c34e-bb98-4705-a34f-55588e26072a%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to