Introduction
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.
Prerequisites: gRPC, HTTP/JSON, Protobuf
About gRPC-Gateway
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.
How does it work?
Architecture of gRPC-Gateway
Demonstration Hello World gRPC-Gateway
main.go
where we will write our client and server logic.References
Twitter: @therajiv
Portfolio: https://iamrajiv.github.io