{"id":25122448,"url":"https://github.com/adiprerepa/grpc-gateway-example","last_synced_at":"2026-06-15T20:31:33.895Z","repository":{"id":107809369,"uuid":"229183017","full_name":"adiprerepa/grpc-gateway-example","owner":"adiprerepa","description":"Fully Implemented gRPC-gateway example in golang.","archived":false,"fork":false,"pushed_at":"2019-12-20T03:36:36.000Z","size":7,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-08-24T18:57:11.188Z","etag":null,"topics":["example-api","golang","grpc","grpc-gateway","grpc-go"],"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/adiprerepa.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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2019-12-20T03:28:22.000Z","updated_at":"2020-01-18T05:31:21.000Z","dependencies_parsed_at":null,"dependency_job_id":"0f79bed0-1aee-443c-bcd7-d0afa72629e9","html_url":"https://github.com/adiprerepa/grpc-gateway-example","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/adiprerepa/grpc-gateway-example","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/adiprerepa%2Fgrpc-gateway-example","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/adiprerepa%2Fgrpc-gateway-example/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/adiprerepa%2Fgrpc-gateway-example/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/adiprerepa%2Fgrpc-gateway-example/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/adiprerepa","download_url":"https://codeload.github.com/adiprerepa/grpc-gateway-example/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/adiprerepa%2Fgrpc-gateway-example/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":34379915,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-26T15:22:16.424Z","status":"online","status_checked_at":"2026-06-15T02:00:07.085Z","response_time":63,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":["example-api","golang","grpc","grpc-gateway","grpc-go"],"created_at":"2025-02-08T07:13:27.624Z","updated_at":"2026-06-15T20:31:33.879Z","avatar_url":"https://github.com/adiprerepa.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# grpc-gateway example\nFully Implemented gRPC-Gateway example in golang.\n\n# Setup\nRun the following Commands to install the following packages into your `$GOPATH`\n```\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\ngo get -u github.com/golang/protobuf/protoc-gen-go\n```\nThen, To generate the client and proxy files, run:\n```\n./gen_grpc_stubs.sh\n```\nThis should place generated file in your `$GOPATH`. Troubleshoot as required.\n\n# Explanation\nThe way the entire world communicates is REST, with JSON. Google open-sourced gRPC in 2015, and it took the tech industry by storm. It goes perfectly hand in hand in microservice communication and with golang. Grpc-Gateway is an API to assist with the runtime translation of JSON into Protocol Buffers, the exchange format used by gRPC, and back. It generates a proxy attached to your microservice, which recieves the data and parses it into protobuf/json for you. It is a great tool to help companies adapt gRPC without rewriting their entire existing architecture, as well. It is a very powerful translation layer.\n\n## Code Explanation\nThere are two golang files - `main.go` and `service.go`. `main.go` is the proxy itself that connects to the service running in `service.go`, where the server work is being done, and the request being handled. \n\n# Running\nTo Build both programs, run:\n```\ngo build main.go\ngo build service.go\n```\nThis will generate 2 executables, `main` and `service`. Run `service` first with `./service` because main connects to service. (ie the proxy connects to the service). This is crucial. After running `./service`, run `./main`, and the service as a whole should work.\n\n# Test with Curl\nIf you have curl installed, run the command:\n```\ncurl -d '{\"val1\":10, \"val2\":10, \"operation_type\" :\"Multiplication\"}' -H \"Content-Type: application/json\" -X POST http://localhost:8081/api/v1/perform_operation\n```\nHere, `\"val1\"` and `\"val2\"` are the arguments for the math evaluation, and the `\"operation_type\"` string specifies the calculation type. The endpoint itself was defined in `example_service.proto`. You should see a response(json) like:\n```\n{\"response\":\"100\",\"operation_valid\":true}\n```\nThe service is being implemented with gRPC, but we communicate with it using REST.\n\n# Author\n- Aditya Prerepa 2019.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fadiprerepa%2Fgrpc-gateway-example","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fadiprerepa%2Fgrpc-gateway-example","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fadiprerepa%2Fgrpc-gateway-example/lists"}