Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/indiependente/gw-example
gRPC Gateway example Go project
https://github.com/indiependente/gw-example
go grpc grpc-gateway grpc-go
Last synced: 5 days ago
JSON representation
gRPC Gateway example Go project
- Host: GitHub
- URL: https://github.com/indiependente/gw-example
- Owner: indiependente
- License: mit
- Created: 2019-08-14T17:16:07.000Z (over 5 years ago)
- Default Branch: main
- Last Pushed: 2023-02-25T19:50:46.000Z (almost 2 years ago)
- Last Synced: 2024-06-19T16:44:02.211Z (7 months ago)
- Topics: go, grpc, grpc-gateway, grpc-go
- Language: Go
- Size: 12.8 MB
- Stars: 0
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# GW Example
## gRPC Gateway example project
### What is it?
___
This is a simple Echo&Reverse gRPC Server, which uses [gRPC-gateway](https://grpc-ecosystem.github.io/grpc-gateway/) to communicate also via REST.### Usage
Make sure you have all the dependencies:
```bash
brew install golang
brew install buf
```Run it on your machine:
```bash
make build
./bin/service
```If you want to use *REST*:
You just need a standard HTTP client to invoke the **echo** endpoint
```bash
$ curl localhost:8080/v1/example/echo -d '{"value":"Hello gRPC!"}'
{"value":"Hello gRPC"}
```Or the **reverse** endpoint:
```bash
$ curl localhost:8080/v1/example/reverse -d '{"value":"Hello gRPC!"}'
{"value":"!CPRg olleH"}
```If you want to use *gRPC*:
This will build the client executable and let it communicate to the server via gRPC.
The client is cli application that currently supports the `!echo` and `!reverse` commands (use `!quit` to exit).```bash
$ make build-client
$ ./bin/client
2019/08/14 18:13:31 Connecting to gRPC server @ 0.0.0.0:9090
Commands: !echo, !reverse, !quit
cmd> !echo
Type a message > Hello World
2019/08/14 18:13:37 client >>> Hello World
2019/08/14 18:13:37 server >>> Hello World
cmd> !reverse
Type a message > Hello World
2019/08/14 18:13:44 client >>> Hello World
2019/08/14 18:13:44 server >>> dlroW olleH
cmd> !quit
2019/08/14 18:13:48 Client shutting down...
```### Usage with Docker
```bash
make docker
docker-compose up
```Use a gRPC or HTTP client as showed above to interact with the server.