use same request or response for multiple RPC

  Kiến thức lập trình

I encountered the error

path-to/my_service.proto:25:3:”c.BookRequest” is used as the request or response type for multiple RPCs.

I have created a couple of RPC that have same request structure.

rpc GetTitle(BookRequest)returns (TitleResponse){}
rpc GetPrice(BookRequest) returns (PriceResponse){}

Message BookRequest {
  int book_id = 1
}

The same applies to RPC that returns book list, I would like to used BookResponse for all of them

Message BookResponse {
  repeated Book books = 1
}

Do I have to create almost identical requests and responses for them? Or there is anyway to reuse them?

2

LEAVE A COMMENT