title: gRPC context on the client side
body: <p>I am building a client/server system in go, using gRPC and protobuf (and with a gRPC gateway to REST).</p>
  
  <p>I use <a href="https://godoc.org/google.golang.org/grpc/metadata" rel="noreferrer">metadata</a> in the context on the server side to carry authentication data from the client, and that works perfectly well.</p>
  
  <p>Now, I'd like the server to set some metadata keys/values so that the client can get them, alongside with the response. How can I do that? Using <a href="https://godoc.org/google.golang.org/grpc#SetHeader" rel="noreferrer">SetHeader</a> and <a href="https://godoc.org/google.golang.org/grpc#SendHeader" rel="noreferrer">SendHeader</a>? Ideally, I'd like every single response from the server to integrate that metadata (can be seen as some kind of <a href="https://godoc.org/google.golang.org/grpc#UnaryServerInterceptor" rel="noreferrer">UnaryInterceptor</a>, but on the response rather than the request?)</p>
  
  <p>Here is the code for the <a href="https://gitlab.com/pantomath-io/demo-grpc/blob/add-auth/server/main.go" rel="noreferrer">server</a> and for the <a href="https://gitlab.com/pantomath-io/demo-grpc/blob/add-auth/client/main.go" rel="noreferrer">client</a>.</p>