talira

gRPC-Gateway

protoc plugin that generates a REST/JSON reverse proxy for your gRPC services

open sourceBSD-3-Clausefree

gRPC-Gateway is a plugin for the protocol buffers compiler that reads your protobuf service definitions and generates a reverse-proxy server in Go, which translates a RESTful HTTP/JSON API into gRPC calls, following the google.api.http annotations. So you can serve the same API over gRPC and REST. It also comes with protoc-gen-openapiv2, which generates OpenAPI (Swagger 2.0) definitions from the same files, and an alpha protoc-gen-openapiv3 for OpenAPI 3.1. It works with protoc or buf generate. The gRPC Ecosystem project maintains it.

Problems it solves

  • serve a REST JSON API alongside my gRPC service without writing it twice
  • generate an HTTP gateway from my protobuf definitions in Go
  • get an OpenAPI spec from my .proto service definitions

Features

  • generates a Go reverse proxy that serves a REST/JSON API in front of gRPC
  • follows google.api.http annotations for paths, query strings and request bodies
  • maps server streaming to newline-delimited JSON
  • maps HTTP headers to gRPC metadata and sets gRPC timeouts
  • turns PATCH requests into field-mask updates
  • generates OpenAPI (Swagger 2.0) definitions with protoc-gen-openapiv2

Limitations

  • Its makers don't plan to support method parameters in HTTP headers, trailer metadata, XML bodies or true bidirectional streaming.1
  • protoc-gen-openapiv3 (OpenAPI 3.1 output) is alpha: its output may change between minor releases, and protoc-gen-openapiv2 is the stable option.1

Alternatives

The same job

These do what gRPC-Gateway does.

  1. Kratos Go microservices framework for the cloud-native era

Compare gRPC-Gateway with the top 3