How can I convert RESTful requests to gRPC requests in my gateway?

This page summarizes the projects mentioned and recommended in the original post on /r/golang

Our great sponsors
  • WorkOS - The modern identity platform for B2B SaaS
  • InfluxDB - Power Real-Time Data Analytics at Scale
  • SaaSHub - Software Alternatives and Reviews
  • go-zero

    A cloud-native Go microservices framework with cli tool for productivity.

  • I'm writing a simple gateway for go-zero, but I don't know what's the best practices on converting RESTful to gRPC requests.

  • grpc-gateway

    gRPC to JSON proxy generator following the gRPC HTTP spec

  • Take a look at https://github.com/grpc-ecosystem/grpc-gateway - should be a good starting point.

  • WorkOS

    The modern identity platform for B2B SaaS. The APIs are flexible and easy-to-use, supporting authentication, user identity, and complex enterprise features like SSO and SCIM provisioning.

    WorkOS logo
  • grpc-web

    gRPC for Web Clients

  • Envoy and https://github.com/grpc/grpc-web are an option.

  • gRPC

    The C based gRPC (C++, Python, Ruby, Objective-C, PHP, C#)

  • I would do this by first requiring that grpc servers all enable server reflection. Then your gateway can just be configured with the endpoint address of the server and a grpc service name, and the gateway can then use the server reflection protocol to pull back the required descriptors. Then using protobuf reflection, walk the methods of the service and extract all the google.api.http annotations to set up an http mux to serve on the paths specified by the annotations. The mux handlers would use the annotations to translate the path/payload into a grpc request which you send to the grpc server.

NOTE: The number of mentions on this list indicates mentions on common posts plus user suggested alternatives. Hence, a higher number means a more popular project.

Suggest a related project

Related posts