Comment by catchmeifyoucan
Comment by catchmeifyoucan 2 days ago
I wonder if we can write an API w/ JSON the usual way and change the final packaging to send it over protobuf.
Comment by catchmeifyoucan 2 days ago
I wonder if we can write an API w/ JSON the usual way and change the final packaging to send it over protobuf.
Sure... https://protobuf.dev/programming-guides/json/
I was pushing at one point for us to have some code in our protobuf parsers that would essentially allow reading messages in either JSON or binary format, though to be fair there's some overhead that way by doing some kind of try/catch, but, for some use cases I think it's worth it...
If you're using Go then this framework let's you work with protobufs and gives you a JSON rest-like service for free: https://github.com/grpc-ecosystem/grpc-gateway
envoy (the proxy) can transcode RESTful APIs to internal grpc services and vice versa. you can even map like url params etc. to proto fields. it works well, even server streaming.