Skip to content

This repository use grpc-gateway, envoy, and denny to create a REST API gateway for GRPC service.

Notifications You must be signed in to change notification settings

trinhdaiphuc/Example-CRUD-with-Mongo-use-http-transcoding-to-gRPC

Repository files navigation

Example project using gRPC and http transcoding

This project is an example using gRPC gateway, Envoy proxy to transcode gRPC API server into REST API server. Furthermore, I use denny framework which is not transcode gRPC API server into REST API server. Denny not only exposes gRPC and http api server in 1 port but also invoke the code you wrote in grpc functions, does not trigger grpc call when you call http.

Generate gRPC stub

Generating client and server code and reverse-proxy for your REST API:

make gen-protobuf

Start project

  • Run all project
make dc-all
  • Use grpc gateway
make dc-gateway
  • Use envoy
make dc-envoy
  • Use denny
make dc-denny

Example API Calls:

Install extension REST client on VS Code for easy send api call with *.http files in /client folder

  • List entities
curl -X GET 'http://localhost:8080/entities'
  • Create entity
curl -X POST 'http://localhost:8080/entities' -d '{"name":"Phuc qua dep trai","description":"Kha la banh","url":"phucdeptrai.com.vn"}'
  • Read entity
curl -X GET "http://localhost:8080/entities/5d11e96b9dadaf6eef8599be"
  • Update entity
curl -X PUT 'http://localhost:8080/entities' -d '{"id":"5dff0ab0ac327677d38754dd","name":"Phuc dep trai vai","description":"Qua la banh","url":"phuchotboy.com.vn"}'
  • Delete entity
curl -X DELETE "http://localhost:8080/entities/5d11e8ee9dadaf6eef8599b9"

About

This repository use grpc-gateway, envoy, and denny to create a REST API gateway for GRPC service.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published