{"id":20153011,"url":"https://github.com/bvwells/grpc-gateway-example","last_synced_at":"2026-05-09T00:03:18.449Z","repository":{"id":57532939,"uuid":"264282711","full_name":"bvwells/grpc-gateway-example","owner":"bvwells","description":"Example usage of gRPC gateway","archived":false,"fork":false,"pushed_at":"2020-07-14T17:27:56.000Z","size":1307,"stargazers_count":3,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-01-13T12:19:58.036Z","etag":null,"topics":["go","golang","grpc","grpc-gateway","openapi","swagger"],"latest_commit_sha":null,"homepage":null,"language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/bvwells.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2020-05-15T19:38:41.000Z","updated_at":"2022-06-13T21:42:45.000Z","dependencies_parsed_at":"2022-09-26T18:20:47.437Z","dependency_job_id":null,"html_url":"https://github.com/bvwells/grpc-gateway-example","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bvwells%2Fgrpc-gateway-example","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bvwells%2Fgrpc-gateway-example/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bvwells%2Fgrpc-gateway-example/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bvwells%2Fgrpc-gateway-example/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/bvwells","download_url":"https://codeload.github.com/bvwells/grpc-gateway-example/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":241592838,"owners_count":19987436,"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":["go","golang","grpc","grpc-gateway","openapi","swagger"],"created_at":"2024-11-13T23:16:27.619Z","updated_at":"2026-05-09T00:03:13.398Z","avatar_url":"https://github.com/bvwells.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# gRPC Gateway Example\n\n[![go.dev reference](https://img.shields.io/badge/go.dev-reference-007d9c?logo=go\u0026logoColor=white\u0026style=flat-square)](https://pkg.go.dev/github.com/bvwells/grpc-gateway-example?tab=overview)\n![GitHub go.mod Go version](https://img.shields.io/github/go-mod/go-version/bvwells/grpc-gateway-example)\n![GitHub release (latest SemVer)](https://img.shields.io/github/v/release/bvwells/grpc-gateway-example) \n[![Build Status](https://travis-ci.com/bvwells/grpc-gateway-example.svg?branch=master)](https://travis-ci.com/bvwells/grpc-gateway-example)\n[![codecov](https://codecov.io/gh/bvwells/grpc-gateway-example/branch/master/graph/badge.svg)](https://codecov.io/gh/bvwells/grpc-gateway-example)\n[![Go Report Card](https://goreportcard.com/badge/github.com/bvwells/grpc-gateway-example)](https://goreportcard.com/report/github.com/bvwells/grpc-gateway-example)\n\nThis repo contains an example usage of grpc gateway (https://github.com/grpc-ecosystem/grpc-gateway).\n\n## Developing\n\nInstall protoc (https://github.com/protocolbuffers/protobuf)\n\n```\nbrew install protobuf\n```\n\nRun \n\n```\ngo mod tidy\n```\n\n```\ngo install \\\n    github.com/grpc-ecosystem/grpc-gateway/protoc-gen-grpc-gateway \\\n    github.com/grpc-ecosystem/grpc-gateway/protoc-gen-swagger \\\n    github.com/golang/protobuf/protoc-gen-go \\\n    golang.org/x/tools/cmd/stringer \\\n    github.com/vektra/mockery/cmd/mockery \\\n    github.com/golangci/golangci-lint/cmd/golangci-lint\n```\n\nAdd $GOBIN to path\n\n```\nexport PATH=$PATH:~/go/bin\n```\n\n## Code generation \n\nFrom root of repo run:\n\n```\ngo generate ./...\n```\n\nThis will re-generate required code. Go generate will generate grpc server/client\nstubs, the grpc gateway reverse proxy and open api definition for the protobuf\ndefinition. These commands can be run independently by running the following\ncommands.\n\n### Generate gRPC server/client stub\n\n```\nprotoc -I. --go_out=plugins=grpc,paths=source_relative:./ api.proto\n```\n\n### Generate reverse-proxy using protoc-gen-grpc-gateway\n\n```\nprotoc -I. --grpc-gateway_out=logtostderr=true,paths=source_relative:./ api.proto \n```\n\n### Generate swagger definitions using protoc-gen-swagger\n\n```\nprotoc -I. --swagger_out=disable_default_errors=true,logtostderr=true:../api/openapi-spec api.proto\n```\n\n## Run PostgreSQL database\n\nTo install PostgreSQL (https://www.postgresql.org/) run:\n\n```\nbrew install postgresql\n```\n\nRun the docker image postgres (https://hub.docker.com/_/postgres):\n\n```\ndocker run --rm --name beers -e POSTGRES_PASSWORD=ilovebeer -p 5432:5432 -v $HOME/Git/github.com/bvwells/grpc-gateway-example/pkg/infrastructure/postgres:/var/lib/postgresql/data postgres\n```\n\nNOTE: The environment variable POSTGRES_PASSWORD should be set to a secret when running in a real environment.\n\nConnect to running instance:\n\n```\npsql -h localhost -U postgres -d postgres\n```\n\nTo create the beers database run:\n```\nCREATE DATABASE BEERS;\n```\n\nConnect to the database:\n```\n\\c beers\n```\n\nTo create the beers table run:\n```\nCREATE TABLE BEERS (\n  id VARCHAR(36) PRIMARY KEY,\n  name TEXT,\n  type INT,\n  brewer TEXT,\n  country TEXT\n);\n```\n\nSome useful psql commands:\n\nList databases:\n```\n\\l \n```\n\nConnect to a database:\n```\n\\c table_name username\n\n```\nList tables:\n```\n\\dt \n```\n\nDescribe a table:\n```\n\\d table_name\n```\n\nHelp:\n```\n\\? table_name\n```\n\n## TODOs\n\n- What to do with request headers?\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbvwells%2Fgrpc-gateway-example","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbvwells%2Fgrpc-gateway-example","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbvwells%2Fgrpc-gateway-example/lists"}