Prerequisites: gRPC, HTTP/JSON, Protobuf
gRPC doesn't have a default speed advantage over REST, but it provides features that can help enhance its speed.
We all know that gRPC is not a tool for everything. There are cases where we still want to provide a traditional HTTP/JSON API. The reasons can range from maintaining backward compatibility to supporting programming languages or clients not well supported by gRPC. But writing another service just to expose an HTTP/JSON API is quite a time-consuming and tedious task.
The gRPC-Gateway is a plugin of the Google protocol buffers compiler protoc
. It reads protobuf service definitions and generates a reverse-proxy server which translates a RESTful HTTP API into gRPC. This server is generated according to the google.api.http
annotations in your service definitions.
This helps you provide your APIs in both gRPC and HTTP/JSON format at the same time.
main.go
where we will write our client and server logic.Portfolio: https://iamrajiv.github.io
GitHub: https://github.com/iamrajiv
LinkedIn: https://www.linkedin.com/in/iamrajivranjansingh
Twitter: https://twitter.com/therajiv