Avatar (Fabio Alessandro Locati|Fale)'s blog

gRPC-Gateway 2 in Fedora

February 22, 2022

gRPC is a very nice technology that allows the implementation of efficient APIs in a very efficient way. Thanks to gRPC and protobuf, you do not have to write much boilerplate code since the boilerplate code is generated automatically from the proto file. This works perfectly until both your client and server can perform gRPC calls. Luckily most of the languages have no issue with this. Still, the big exception is JavaScript (and other languages that will compile to JS, such as TypeScript) running in a browser.

The issue with JavaScript in the browsers is that to implement gRPC, the gRPC library needs to handle the HTTP connection directly, and this is not allowed in browsers. There are, therefore, different ways to make gRPC API work with browsers. The two most famous ones are gRPC-Gateway and gRPC-Web.

I usually use gRPC-Gateway, since it allows me to create a full RESTful JSON API from the gRPC API without running any additional process. gRPC-Gateway can also create a Swagger/OpenAPI definition of the APIs so that you do not have to.

In the Fedora repositories, there has been version 1 of gRPC-Gateway for quite some time, and since today there is also version 2. Version 2 brings many changes, starting from the support for the Go APIv2 Protobuf stack.

You can install gRPC-Gateway version 2 simply by issuing the following command:

sudo dnf install golang-github-grpc-ecosystem-gateway-2

On the other hand, gRPC-Gateway version 1 is still available, so if you need that version instead, you can run:

sudo dnf install golang-github-grpc-ecosystem-gateway

I hope many other people will find this tool as helpful as I found it.