Our great sponsors
-
WorkOS
The modern identity platform for B2B SaaS. The APIs are flexible and easy-to-use, supporting authentication, user identity, and complex enterprise features like SSO and SCIM provisioning.
I'm writing a simple gateway for go-zero, but I don't know what's the best practices on converting RESTful to gRPC requests.
Take a look at https://github.com/grpc-ecosystem/grpc-gateway - should be a good starting point.
Envoy and https://github.com/grpc/grpc-web are an option.
I would do this by first requiring that grpc servers all enable server reflection. Then your gateway can just be configured with the endpoint address of the server and a grpc service name, and the gateway can then use the server reflection protocol to pull back the required descriptors. Then using protobuf reflection, walk the methods of the service and extract all the google.api.http annotations to set up an http mux to serve on the paths specified by the annotations. The mux handlers would use the annotations to translate the path/payload into a grpc request which you send to the grpc server.