gogrpchttp2grpc-go

How to retrieve metadata from grpc response using grpcdynamic from github.com/jhump/protoreflect


Does anyone know how to get the incoming metadata from the server after making a grpc invoke call in client like response, err := grpcClient.InvokeRpc(context.TODO(), methodDesc, message)

I am using https://github.com/jhump/protoreflect, you can refer to a sample code here.


Solution

  • I found the solution, I just have to pass the additional arguments asking for metadata, Check this!. Also it has nothing to do with github.com/jhump/protoreflect

    var header, trailer metadata.MD // variable to store header and trailer
    r, err := client.SomeRPC(
    ctx,
    someRequest,
    grpc.Header(&header),    // will retrieve header
    grpc.Trailer(&trailer),  // will retrieve trailer
    )
    
    // do something with header and trailer