I'm using grpc-gateway
inside same go app, to proxy convert HTTP to GRPC. As far as I see by default grpc-gateway
sets application application/json
format for all rpcs, including streaming.
So, my task is:
- Incoming HTTP requests MUST always be
Content-type: application/json
, otherwise request should be rejected and 406 sent according to RFC. - Incoming HTTP request MAY have
Accept: application/x-ndjson
set for unary RPCs andAccept: applcation/x-ndjson
header set for server streams. If conditions don't met 406, should be returned. - Outgoing HTTP request MUST set
Content-type: applicaiton/json
, for simple unary RPCs, andContent-type: application/x-ndjson
for server streams.
So, grpc-gateway
proposes only to set custom marshaller, for application/x-ndjson
, which would do actually the same as default one, so with just overwritten ContentType
method. This approach not allowing me to set marshaler per method call, and doesn't allow me to reject unsupported content type per request.
How can I achieve this still using grpc-gateway
? Or I should consider then implementing http grpc conversion manually?