gw-example

command module
v0.0.0-...-c3390c3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 25, 2023 License: MIT Imports: 13 Imported by: 0

README

GW Example

gRPC Gateway example project

What is it?

This is a simple Echo&Reverse gRPC Server, which uses gRPC-gateway to communicate also via REST.

Usage

Make sure you have all the dependencies:

brew install golang
brew install buf

Run it on your machine:

make build
./bin/service

If you want to use REST:

You just need a standard HTTP client to invoke the echo endpoint

$ curl localhost:8080/v1/example/echo -d '{"value":"Hello gRPC!"}'
{"value":"Hello gRPC"}

Or the reverse endpoint:

$ 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).

$ 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
make docker
docker-compose up

Use a gRPC or HTTP client as showed above to interact with the server.

Documentation

The Go Gopher

There is no documentation for this package.

Directories

Path Synopsis
rpc
service/v1
Package servicev1 is a reverse proxy.
Package servicev1 is a reverse proxy.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL