My REST API must work with gRPC objects as input parameters.
The most simple example is:
GET http://localhost:8083/api/books?page.number=1&page.size=30
where the proto definition is:
message PagedMessage {
Page page = 1;
}
message Page {
int32 number = 1;
int32 size = 2;
}
The controller is:
@RequestMapping(value = "/api/books")
public class ObjectOps {
@Autowired
private BooksService booksService;
@GetMapping(value = "/")
@ResponseBody
BooksList listBooks(@RequestParam PagedMessage request) {
return booksService.getBooks(request);
}
}
And in the application I have this bean:
@Bean
ProtobufJsonFormatHttpMessageConverter protobufJsonFormatHttpMessageConverter() {
return new ProtobufJsonFormatHttpMessageConverter();
}
The only way it worked for me is to pass the paging information as GET body:
{
"page" : {
"number": 1,
"size": 30
}
}
but it will be great to have the list books method object be populated from the request path parameters.