{"id":26468681,"url":"https://github.com/dray92/go-grpc-tutorial","last_synced_at":"2026-04-16T13:36:05.438Z","repository":{"id":57647994,"uuid":"135087922","full_name":"dray92/go-grpc-tutorial","owner":"dray92","description":"gRPC sample with gRPC gateway + Swagger UI","archived":false,"fork":false,"pushed_at":"2019-01-13T20:29:03.000Z","size":21,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-03-12T07:08:22.682Z","etag":null,"topics":["golang","grpc","grpc-gateway","grpc-swagger","python"],"latest_commit_sha":null,"homepage":null,"language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/dray92.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2018-05-27T23:06:47.000Z","updated_at":"2019-01-13T01:23:30.000Z","dependencies_parsed_at":"2022-08-25T08:10:25.454Z","dependency_job_id":null,"html_url":"https://github.com/dray92/go-grpc-tutorial","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dray92%2Fgo-grpc-tutorial","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dray92%2Fgo-grpc-tutorial/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dray92%2Fgo-grpc-tutorial/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dray92%2Fgo-grpc-tutorial/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/dray92","download_url":"https://codeload.github.com/dray92/go-grpc-tutorial/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":244460247,"owners_count":20456301,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["golang","grpc","grpc-gateway","grpc-swagger","python"],"created_at":"2025-03-19T16:15:07.166Z","updated_at":"2026-04-16T13:36:05.406Z","avatar_url":"https://github.com/dray92.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# gRPC Tutorial + Swagger JSON\nBasic tutorial into setting up a gRPC reverse proxy that will\ntransform REST JSON into gRPC, along with instructions on how\nto generate Swagger definitions.\nInstructions on how to run client/server in other languages.\n\n## Goals\n- service defintion in `service.proto`\n- generate client and server code using [`protoc`](https://github.com/google/protobuf).\n- wrap generated code to expose light client (and server).\n- generate gateway code for HTTP/JSON reverse proxy.\n\n## TODO\n- get Swagger UI to render service's Swagger JSON (with auth)\n- auth definitions in proto\n- investigate python reverse proxy support [#398](https://github.com/grpc-ecosystem/grpc-gateway/issues/398)\n- write up instructions for java {[grpc-jersey](https://github.com/fullcontact/grpc-jersey)}\n- find a contributor for nodejs\n\n## Basic Setup\n- use [`gvm`](https://github.com/moovweb/gvm) or something to get Go \u003e= 1.6\n- `brew install protobuf` or `apt install libprotobuf-dev`\n- `$ go help gopath # make sure GOPATH is set`\n\n### Golang installations\n```bash\ngo get google.golang.org/grpc\ngo get -u github.com/golang/protobuf/proto\ngo get -u github.com/golang/protobuf/protoc-gen-go\ngo get -u github.com/grpc-ecosystem/grpc-gateway/protoc-gen-grpc-gateway\ngo get -u github.com/grpc-ecosystem/grpc-gateway/protoc-gen-swagger\n```\n\n## Architecture\nThis is the basic architecture of a grpc-gateway application {from [`grpc-ecosystem/grpc-gateway/`](https://github.com/grpc-ecosystem/grpc-gateway/)}.\n\n![Architecture](https://camo.githubusercontent.com/e75a8b46b078a3c1df0ed9966a16c24add9ccb83/68747470733a2f2f646f63732e676f6f676c652e636f6d2f64726177696e67732f642f3132687034435071724e5046686174744c5f63496f4a707446766c41716d35774c513067677149356d6b43672f7075623f773d37343926683d333730 \"Architecture\")\n\n## Service definition\n[`pb/service.proto`](https://github.com/dray92/go-grpc-tutorial/blob/master/pb/service.proto)\n\n## Golang Client/Server code generation\n[`pb/service.pb.go`](https://github.com/dray92/go-grpc-tutorial/blob/master/pb/service.pb.go)\n\nTo generate:\n```bash\n$ protoc -I/usr/local/include -I. \\\n  -I$GOPATH/src \\\n  -I$GOPATH/src/github.com/grpc-ecosystem/grpc-gateway/third_party/googleapis \\\n  --go_out=google/api/annotations.proto=github.com/grpc-ecosystem/grpc-gateway/third_party/googleapis/google/api,plugins=grpc:. \\\n  pb/service.proto\n```\n\n### Golang Reverse proxy gateway code generation\n[`pb/service.pb.gw.go`](https://github.com/dray92/go-grpc-tutorial/blob/master/pb/service.pb.gw.go)\n\nTo generate:\n```bash\n$ protoc -I/usr/local/include -I. \\\n   -I$GOPATH/src \\\n   -I$GOPATH/src/github.com/grpc-ecosystem/grpc-gateway/third_party/googleapis \\\n   --grpc-gateway_out=logtostderr=true:. \\\n   pb/service.proto\n```\n\n### Golang Client code\n[`client/client.go`](https://github.com/dray92/go-grpc-tutorial/blob/master/client/client.go)\n\n### Golang Server code\n[`server/server.go`](https://github.com/dray92/go-grpc-tutorial/blob/master/server/server.go)\n\n### Golang Reverse proxy server code\n[`server/server-rproxy.go`](https://github.com/dray92/go-grpc-tutorial/blob/master/server/server-rproxy.go)\n\n### Golang Server \u003c-\u003e Client communication\n```bash\ngo run server/server.go\n\n...\n\ngo run client/client.go\n```\n\nWill display ``2018/05/28 12:57:11 Hello debo!``\n\n### Golang Server \u003c-\u003e Client via gRPC Gateway\n```bash\ngo run server/server.go\n\n...\n\ngo run server/server-rproxy.go\n\n...\n\ncurl -X POST \"http://localhost:8080/v1/example/hello/v1/world\" | jq .\n```\n\nWill display \n```json\n{\n  \"id\": \"v1\",\n  \"msg\": \"world\"\n}\n```\n\n## Python Client/Server code generation\n\nPR to update gRPC docs: [#671](https://github.com/grpc/grpc.github.io/pull/671)\n[`pb/service_pb2.py`](https://github.com/dray92/go-grpc-tutorial/blob/master/pb/service_pb2.py)\n[`pb/service_pb2_grpc.py`](https://github.com/dray92/go-grpc-tutorial/blob/master/pb/service_pb2_grpc.py)\n\nTo generate:\n```bash\nvirtualenv env\n. env/bin/activate\n\npip install grpcio-tools googleapis-common-protos\n\npython -m grpc_tools.protoc --python_out=. \\\n  --grpc_python_out=. -I. -I/usr/local/include \\\n  -I$GOPATH/src/github.com/grpc-ecosystem/grpc-gateway/third_party/googleapis \\\n  -I/usr/local/include \\\n  pb/service.proto \n```\n\n### Python Client code\n[`client/client.py`](https://github.com/dray92/go-grpc-tutorial/blob/master/client/client.py)\n\n### Python Server code\n[`server/server.py`](https://github.com/dray92/go-grpc-tutorial/blob/master/server/server.py)\n\n### Python Server \u003c-\u003e Client communication\n```bash\npython -m server.server\n\n...\n\npython -m client.client\n```\n\nWill display ``Hello world!``\n\n### Python Reverse proxy server code\nI don't believe this can be done in the state of the world at the time of writing.\n\n## Generate Swagger JSON\n[`pb/service.swagger.json`](https://github.com/dray92/go-grpc-tutorial/blob/master/pb/service.swagger.json)\n\nTo generate:\n```bash\nprotoc -I/usr/local/include -I. \\\n  -I$GOPATH/src \\\n  -I$GOPATH/src/github.com/grpc-ecosystem/grpc-gateway/third_party/googleapis \\\n  --swagger_out=logtostderr=true:. \\\n  pb/service.proto\n```","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdray92%2Fgo-grpc-tutorial","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdray92%2Fgo-grpc-tutorial","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdray92%2Fgo-grpc-tutorial/lists"}