I have a Micronaut @Controller as follows:
@Post("/whatever")
@Consumes("application/x-protobuf")
@Produces(MediaType.TEXT_PLAIN)
public HttpResponse deserializeData (@Body byte[] body)
throws ProtobufParsingException {
return requestHandler.processDataRequest(body);
}
and a Client that calls this API:
@Client("${protobuf-manager.url}")
public interface ProtobufManagerClient {
@Post("/${protobuf-manager.apiversion}/whatever")
@Consumes(MediaType.TEXT_PLAIN)
@Produces(ProtobufferCodec.PROTOBUFFER_ENCODED)
String getData (@Body byte[] data);
}
The problem is, I need to send my bytes from my byte[] data
param not changing the @Consumes("application/x-protobuf")
in my Controller.
body
is arriving as empty in the Controller.
Any idea?
The issue is that the current Protobuf codec only supports encoding Message types. See https://github.com/micronaut-projects/micronaut-grpc/blob/a00a348028628c170d74bd7267011255c9ac01cd/protobuff-support/src/main/java/io/micronaut/protobuf/codec/ProtobufferCodec.java#L157
It seems to me it should support raw byte[]
as well. Please file an issue with https://github.com/micronaut-projects/micronaut-grpc and PRs are appreciated