Arj*_*ili 7 protocol-buffers google-cloud-endpoints google-cloud-platform grpc protoc
我正在尝试使用Google Cloud Endpoints制作基于gRPC的api,该api可以对传入的REST请求进行转码。我正在遵循他们的示例代码,但是我没有任何有关如何正确地导入和使用注解.proto或empty.proto进行编译的文档。
谢谢!
这可能不是一个好主意。您可以复制google/api/annotations.proto并google/api/http.proto到您的本地项目,并将其导入运行时python -m
mkdir -p google/api
curl https://raw.githubusercontent.com/googleapis/googleapis/master/google/api/annotations.proto > google/api/annotations.proto
curl https://raw.githubusercontent.com/googleapis/googleapis/master/google/api/http.proto > google/api/http.proto
python -m grpc_tools.protoc google/api/http.proto google/api/annotations.proto -I. --python_out=. --grpc_python_out=. your_proto.proto
Run Code Online (Sandbox Code Playgroud)
refurl: https://cloud.google.com/solutions/exposing-grpc-services-using-cloud-endpoints-pt1
我不明白这是grpc-gateway的一部分。通过遵循我运行的文档
protoc -I/usr/local/include -I. -I$GOPATH/src -I$GOPATH/src/github.com/grpc-ecosystem/grpc-gateway/third_party/googleapis --go_out=plugins=grpc:. *.proto
Run Code Online (Sandbox Code Playgroud)
并成功编译。
默认情况下不包含empty.proto和annotation.proto,因此您需要引入副本。具体来说,您可以在项目的目录中复制它们,或者在现有项目(例如 Protobuf git 存储库)中引用它们。
最好不要引用grpc-ecosystem/grpc-gateway 使用的副本,因为他们将来可能想移动它。
| 归档时间: |
|
| 查看次数: |
9072 次 |
| 最近记录: |