A gateway to automatically provide RESTful API for gRPC

API Gateway

A native and easy gateway to provide RESTful API for gRPC, inspired by grpc-gateway, but fully automation.

Prepare:

  • Download&&Install golang/protoc/docker and Env setting.

Usage:

How to define RESTful in *.proto: [custom option]

your_service.proto:

    syntax = "proto3";
    package example;
   +
   +import "google/api/annotations.proto";
   +
    message StringMessage {
      string value = 1;
    }

    service YourService {
   -  rpc Echo(StringMessage) returns (StringMessage) {}
   +  rpc Echo(StringMessage) returns (StringMessage) {
   +    option (google.api.http) = {
   +      post: "/v1/example/echo"
   +      body: "*"
   +    };
   +  }
    }

Enjoy it!

2 个评论

2年前 我就用c++实现了grpc restapi网关。
它属于微服务框架的一部分,提供外部restapi和内部服务的接口适配,而且网关不需要加载内部服务的proto文件。
不加载内部服务的proto文件,你是如何解决的呢?

要回复文章请先登录注册