gRPC-Gateway generates a REST API from gRPC definitions, translating HTTP/JSON requests into gRPC calls for unified service exposure.
gRPC-Gateway automatically generates a REST API layer that translates incoming HTTP/JSON requests into gRPC calls, allowing you to serve both protocols from a single backend. You configure this by defining HTTP annotations in your .proto files and running the protoc compiler with the grpc-gateway plugin to generate the necessary Go code.
protoc -I. \
--go_out=. --go_opt=paths=source_relative \
--go-grpc_out=. --go-grpc_opt=paths=source_relative \
--grpc-gateway_out=. --grpc-gateway_opt=paths=source_relative \
--grpc-gateway_opt=logtostderr=true \
your_service.proto
gRPC-Gateway acts as a translator between two different languages: the fast, binary gRPC protocol used by your internal services and the standard HTTP/JSON format used by web browsers and mobile apps. Instead of writing two separate APIs, you define your service once in a .proto file, and the gateway automatically creates the REST endpoints that forward requests to your gRPC server. It's like having a bilingual receptionist who takes phone calls (HTTP) and instantly relays the message to the specialist (gRPC) without you needing to speak both languages yourself.