Right now I have this proto file that specifies a grpc method that is also an http rest style api using go-grpc-gateway:
rpc GetBars(GetBarReq) returns (GetBarRes) {
option (google.api.http) = {
get : "/v1/bar"
};
};
message Bar {
string a = 1;
string b = 2;
}
message GetBarRes {
repeated Bar bar = 1;
}
message GetBarReq {
string id = 1;
}
I have some golang app logic where I implement the generated structures.
func (s *barServer) GetBars(req *pb.GetBarReq) (*pb.GetBarRes, error) {
...
return &pb.GetBarRes{Bars: bars}, nil
}
which returns:
{
"bars": [
{
"a": "a",
"b": "b"
},
{
"a": "a",
"b": "b"
}
]
}
How could I modify the proto file or my app logic to return this instead:
[
{
"a": "a",
"b": "b"
},
{
"a": "a",
"b": "b"
}
]