Implementing gRPC JSON transcoding
JSON is the most popular format for services that return data to a browser or mobile device. It would be great if we could create a gRPC service and magically make it callable via non-HTTP/2 using JSON.
Thankfully, there is a solution.
Microsoft has a technology they call gRPC JSON transcoding. It is an ASP.NET Core extension that creates HTTP endpoints with JSON for gRPC services, based on Google’s HttpRule class for their gRPC transcoding.
More Information: You can read about Google’s HttpRule class at the following link: https://cloud.google.com/dotnet/docs/reference/Google.Api.CommonProtos/latest/Google.Api.HttpRule.
Enabling gRPC JSON transcoding
Let’s see how to enable gRPC JSON transcoding in our gRPC service:
- In the
Northwind.Grpc.Serviceproject, add a package reference for gRPC JSON transcoding, as shown highlighted in the following markup:<ItemGroup> <...