grpc-gateway

Contents

Roadmap info from roadmap website

Grpc gateway

gRPC-Gateway creates a layer over gRPC services that will act as a RESTful service to a client. It is a plugin of protoc. It reads a gRPC service definition and generates a reverse-proxy server which translates a RESTful JSON API into gRPC.

Visit the following resources to learn more:

gRPC-Gateway__

  • Purpose: Allows RESTful clients to interact with gRPC services.

  • Best For: Providing both REST and gRPC APIs for microservices.

    Example:

    mux := runtime.NewServeMux()
    err := pb.RegisterYourServiceHandlerFromEndpoint(ctx, mux, "localhost:50051", opts)

gRPC-Gateway__ - RESTful API for gRPC Services

Solution Example: Mobile Backend for Streaming Service

  • Use Case: A mobile app interacts with backend services using a REST API, but the backend communicates via gRPC.

  • Framework Usage: The gRPC-Gateway exposes a REST API for the mobile app, while internal services communicate using gRPC.

  • Workflow:

    • The mobile app calls a REST endpoint via gRPC-Gateway.
    • The gateway translates the REST request into a gRPC call to the StreamingService.

    Example:

    mux := runtime.NewServeMux()
    err := pb.RegisterStreamingServiceHandlerFromEndpoint(ctx, mux, "localhost:50051", opts)
#ready #online #reviewed #microservices #go #frameworks