What is gRPC gateway and what problem does it solve?
Answer
grpc-gateway is a plugin for the protoc compiler that generates a reverse proxy HTTP/JSON gateway from annotated .proto files. It solves the browser/REST client compatibility problem: by adding HTTP annotations to your .proto (using google.api.http options), grpc-gateway generates Go code that translates incoming REST/JSON requests to gRPC calls and translates the gRPC responses back to JSON. Example annotation: rpc GetUser(GetUserRequest) returns (User) { option (google.api.http) = { get: "/v1/users/{id}" }; }. This allows you to maintain a single gRPC service definition and expose it as both a gRPC API (for internal microservices) and a REST/JSON API (for browser clients, external partners, or legacy systems) without maintaining two separate server implementations.
Previous
How do you handle backward compatibility in Protobuf?
Next
What is the difference between proto2 and proto3?