I am grpc rookie and wanted to create a REST endpoint for health check of the grpc server. For this I decided to use grpc gateway.
However, the example in docs for grpc-REST gateway for proxying grpc to json are only given for Golang. But I have a backend of python and want to use Google Cloud Endpoints to make a gRPC based api that can transcode incoming REST requests.
I did find a manual method of annotation generation in this stackoverflow answer . But I was wondering what is the best method of doing it. This is the sample .proto file I want to generate into a class.
syntax = "proto3";
package example;
+
+import "google/api/annotations.proto";
+
message StringMessage {
string value = 1;
}
service YourService {
- rpc Echo(StringMessage) returns (StringMessage) {}
+ rpc Echo(StringMessage) returns (StringMessage) {
+ option (google.api.http) = {
+ post: "/v1/example/echo"
+ body: "*"
+ };
+ }
}
How can I generate .proto files and create the grpc-gateway using python backend?
For proto generation, please take a look at our quick start guide for gRPC Python. grpc-gateway project also has a nice tutorial for how to setup the gateway process.