I am using gRPC gateway for the backward compatibility support but I encountered an issue where in our REST APIs we are using the Protobuf with REST. But in gRPC gateway we are using JSON as a response type. Now when we have migrated towards gRPC, but I am not seeing any option where I will receive the response as a proto type not the JSON type. Can someone please help me in this?
I am getting content-type
with the REST url: application/json
What I need: application/x-protobuf
EDIT: I have this service contract
service TestService {
rpc GetBattleStatusByEntityIds(ProtoRequest) returns (ProtoResponse) {
option (google.api.http) = {
get : "/test"
};
}
}
When I am hitting this /test
url then I am receiving the response with content type application/json
but I need the data in application/x-protobuf
format. I checked the grpc-gateway code and it is using a marshaller which change the response from protobuf to json. Can you please help me to keep it like json any code sample would help.
https://github.com/grpc-ecosystem/grpc-gateway/blob/main/runtime/marshal_jsonpb.go
Picture of wanted response type: https://i.stack.imgur.com/jvR3w.png