Skip to content

A gateway to automatically provide RESTful API for gRPC

Notifications You must be signed in to change notification settings

jmzwcn/api-gateway

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

84 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published