gRPC and gRPC gateway sample
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
.circleci
cmd
proto-gen/go/proto/api/v1
proto
server
vendor
.gitignore
Gopkg.lock
Gopkg.toml
LICENSE
Makefile
README.md

README.md

How to run

Installation

$ make setup

Generate go code from proto

$ make proto/go

Run server

$ go run ./cmd/main.go

Call API with curl

Create a new user

$ curl -X POST -d '{"name": "oinume", "real_name": "kazuhiro oinuma"}' http://localhost:5000/v1/users | jq .

{
  "id": "12345",
  "name": "oinume",
  "real_name": "kazuhiro oinuma"
}

Get a user

$ curl -X GET http://localhost:5000/v1/users/1 | jq .

{
  "id": "1",
  "name": "oinume",
  "real_name": "Kazuhiro Oinuma"
}

List users

$ curl -X GET http://localhost:5000/v1/users | jq .

{
  "users": [
    {
      "id": "1",
      "name": "oinume",
      "real_name": "kazuhiro oinuma"
    },
    {
      "id": "2",
      "name": "akuwano",
      "real_name": "Akihiro Kuwano"
    },
    {
      "id": "3",
      "name": "oranie",
      "real_name": "Takashi Narita"
    }
  ]
}

Delete a user

curl -X DELETE http://localhost:5000/v1/users/12345 | jq .

{}