grpc-gateway/

directory
v0.0.0-...-02c9ee4 Latest Latest
Warning

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

Go to latest
Published: Apr 4, 2023 License: MIT

README

gRPC Gateway sample

Compile

make proto

Run gRPC server

go run server/main.go

Run gRPC Gateway

go run gateway/main.go

Send Request

Alive
curl http://localhost:3000/alive

This returns

{"status":true}
Get User
curl http://localhost:3000/user/100

This returns

{"id":"100","name":"Alice","age":20}
Get Users By Group
curl http://localhost:3000/user?group=ADMIN

This returns

{"group":"ADMIN","users":[{"name":"Alice","age":20},{"name":"Bob","age":24}]}
Update User
curl -XPUT http://localhost:3000/user/100 -d '{"name": "bob", "age": 16}'

Then the grpc server's stdout shows

2017/11/14 14:25:52 update body is {id: 100, name: bob, age: 16}

Directories

Path Synopsis
Package gateway is a reverse proxy.
Package gateway is a reverse proxy.

Jump to

Keyboard shortcuts

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