gRPC-gateway how to map string fields to numbers

225 views
Skip to first unread message

Simon Zhu

unread,
Jun 18, 2021, 6:20:22 PM6/18/21
to grpc.io
Hey guys, I'm considering using https://github.com/grpc-ecosystem/grpc-gateway for generating a REST API for my gRPC server, and I was wondering whether it is possible to specify rules for how types are mapped?

For example, I see in the documentation https://github.com/googleapis/googleapis/blob/master/google/api/http.proto that we can specify body to map the request body to a field in the gRPC request parameters.

However, will this work properly if I have a string field in my HTTP request body that is defined as an int or some other type in the protobuf definition? I want to use string for all numbers in my REST API, in order to eliminate loss of precision or ambiguity. And if it will not work properly out of the box, is there a way for me to specify the conversion?
Reply all
Reply to author
Forward
0 new messages