gRPC-Gateway is a protoc plugin that reads gRPC service definitions and emits a reverse-proxy server. It exposes the same backend through RESTful JSON HTTP while following gRPC HTTP mapping rules.
Overview
gRPC-Gateway plugs into the protocol buffers compiler. It consumes protobuf service definitions annotated with google.api.http options and generates Go code for an HTTP reverse proxy that forwards REST JSON calls to a gRPC service.
Teams can ship one gRPC implementation and still offer a JSON HTTP API for browsers, legacy clients, or tooling that expects REST. Mapping can rely on default HTTP semantics, custom annotations in the proto file, or an external gRPC service configuration when the proto is not under your control.
Companion generators emit OpenAPI Swagger or OpenAPI 3.1 descriptions from the same definitions. You implement the gRPC service separately, generate gateway stubs with buf or protoc, then run an entrypoint HTTP server that dials your gRPC backend.
Optional buf remote plugins and released binaries supply the protoc-gen-grpc-gateway and related tools without a local compile step. Documentation walks through annotation patterns, gateway customization, and unescaping modes for path parameters.
Key features
- protoc plugin code generation
- google.api.http annotation mapping
- Default unannotated HTTP mapping
- External gRPC service configuration
- OpenAPI and Swagger generation
- OpenAPI 3.1 generator alpha option
- buf and protoc workflow support
- Standalone gateway package option
Use cases
- Dual gRPC and REST API exposure
- JSON HTTP access to gRPC backends
- OpenAPI docs from protobuf services
- Backward-compatible REST clients