我有一个非常简单的 gRPC 服务,定义为:
syntax = "proto3";
package helloworld;
import "annotations.proto";
// The greeting service definition.
service Greeter {
// Sends a greeting
rpc SayHello(HelloRequest) returns (HelloReply) {
option (google.api.http) = {
post: "/api/v1/hello"
body: "*"
}
}
}
// The request message containing the user's name.
message HelloRequest {
string name = 1;
}
// The response message containing the greetings
message HelloReply {
string message = 1;
}
Run Code Online (Sandbox Code Playgroud)
有趣的是,我使用 Envoy gRPC <> JSON 转码过滤器在 HTTP2/Protobuf <> HTTP1/JSON 之间进行“翻译”。有关更多详细信息,请参阅https://www.envoyproxy.io/docs/envoy/latest/api-v1/http_filters/grpc_json_transcoder_filter …