A gateway to automatically provide RESTful API for gRPC

jmzwcn發表於2018-02-10

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!

相關文章