I have used protobufs to define my models and gRPC service, and generated protos for Go (.pb.go). When I make gRPC call to a service, I want to find out in server the name of the client/application calling the server API. Can the context parameter in the API be of any help here?
Asked
Active
Viewed 1,198 times
2 Answers
2
You can use the WithUserAgent
dial option to set a custom user agent string on the client.
For retrieving the user agent on the server side, see this question. It's not fully answered, but you can just print the metadata map and see how the user agent gets stored in the metadata. And then post your findings there :)

Thomas
- 174,939
- 50
- 355
- 478
1
As an option, you can use GRPC Metadata. It's not strong typed (because it's just map[string][]string
), but may fit your needs good. Set custom metadata field on client side and check this field in server handler.

Vitaly Isaev
- 5,392
- 6
- 45
- 64