问题描述
我试图在没有 streaimg API 的情况下从 grpc 返回项目列表并且没有找到任何解决方案或示例,我知道我们在使用流式传输时使用这种 proto file
message ListBlogResponse {
Blog blog = 1;
}
然后Blog
message Blog {
string id = 1;
string author_id = 2;
string title = 3;
string content = 4;
}
但我想在不使用任何流媒体的情况下发送一次响应,如下所示:
return &api.ListBlogResponse{
Blog: items,},nil
这个的原型文件是什么?
解决方法
您需要包含多个博客的消息:
message BlogEntries {
repeated Blog blog = 1;
}
然后你可以返回:
return &BlogEntries{Blog:entries},nil