【发布时间】:2019-09-28 22:15:09
【问题描述】:
当curling GRPC protobuf 中的 REST 注释端点时,我没有收到有效响应
我目前正在从here 运行bookstore server
我已经能够使用提供的客户端通过 GRPC 成功访问端点。
$ python bookstore_client.py
ListShelves: shelves {
id: 1
theme: "Fiction"
}
shelves {
id: 2
theme: "Fantasy"
}
当我尝试点击相应的 REST 端点时,它会返回一个非文本(即非 JSON)响应
$ curl --raw --http2 localhost:8000/v1/shelves 2>/dev/null | xxd
00000000: 0000 1804 0000 0000 0000 0400 4000 0000 ............@...
00000010: 0500 4000 0000 0600 0020 00fe 0300 0000 ..@...... ......
00000020: 0100 0004 0800 0000 0000 003f 0001 0000 ...........?....
00000030: 0806 0000 0000 0000 0000 0000 0000 00 ...............
无论 uri 是什么,我都会收到此响应,即/v1/foobar 给出相同的结果
这是来自protobuf的相关行
rpc ListShelves(google.protobuf.Empty) returns (ListShelvesResponse) {
// Define HTTP mapping.
// Client example (Assuming your service is hosted at the given 'DOMAIN_NAME'):
// curl http://DOMAIN_NAME/v1/shelves
option (google.api.http) = { get: "/v1/shelves" };
}
我希望得到与 python 客户端相同的响应,但我收到了来自 GRPC 服务器的非文本响应。
【问题讨论】: