jmzwcn / api-gateway

A gateway to automatically provide RESTful API for gRPC

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

API Gateway

A native and easy gateway to provide RESTful API for gRPC, inspired by grpc-gateway, but fully automatic, also support bi-directional streaming(websocket).

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!


About

A gateway to automatically provide RESTful API for gRPC


Languages

Language:Go 82.1%Language:Makefile 15.5%Language:Dockerfile 2.4%