{"id":19273599,"url":"https://github.com/zikwall/gateway","last_synced_at":"2026-05-15T22:31:00.792Z","repository":{"id":104958242,"uuid":"571953001","full_name":"zikwall/gateway","owner":"zikwall","description":"Gateway: library HTTP over gRPC","archived":false,"fork":false,"pushed_at":"2022-11-29T09:01:44.000Z","size":38,"stargazers_count":0,"open_issues_count":1,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-01-05T14:24:26.930Z","etag":null,"topics":["gateway","go","golang","grpc"],"latest_commit_sha":null,"homepage":"","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/zikwall.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":"2022-11-29T08:43:20.000Z","updated_at":"2022-11-29T08:51:26.000Z","dependencies_parsed_at":null,"dependency_job_id":"af41e97a-ec18-47ec-831d-d2511540edf8","html_url":"https://github.com/zikwall/gateway","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/zikwall%2Fgateway","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zikwall%2Fgateway/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zikwall%2Fgateway/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zikwall%2Fgateway/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/zikwall","download_url":"https://codeload.github.com/zikwall/gateway/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":240378869,"owners_count":19792039,"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":["gateway","go","golang","grpc"],"created_at":"2024-11-09T20:43:35.755Z","updated_at":"2025-10-06T21:13:41.050Z","avatar_url":"https://github.com/zikwall.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"## Gateway: library HTTP over gRPC\n\nAn additional way to access our gRPC service with little effort (easier than writing your own code and serializer), \nwhich can be useful in a number of cases.\n\n### How to use?\n\n0. Create config file\n\n```yaml\nservices:\n  - service: \"some\"\n    url: \"grpc://0.0.0.0:1337\"\n    prefix: \"/some\"\n    auth: false\n    endpoints:\n     - /v1/public/handler_one\n     - /v1/private/handler_two\ndefault:\n  service: \"Default\"\n  url: \"http://0.0.0.0:80\"\n```\n\n2. Define proto file, see example [proto](./example/simple/proto/some/v1/some.proto)\n\n**Note**: it is necessary to use `grpc-gateway_*` flags when generating protobuf code, [example](./example/simple/Makefile)\n\n```shell\n--grpc-gateway_out=./proto/$@/v1 \\\n--grpc-gateway_opt=logtostderr=true \\\n--grpc-gateway_opt=paths=source_relative \\\n```\n\n```protobuf\nsyntax = \"proto3\";\n\npackage Some.V1;\n\n// require import\nimport \"google/api/annotations.proto\";\n\nservice Some {\n  rpc HandlerOne (...) returns (...) {\n    option (google.api.http) = {\n      get: \"/v1/public/handler_one\"\n    };\n  };\n\n  rpc HandlerTwo (...) returns (...) {\n    option (google.api.http) = {\n      post: \"/v1/private/handler_two\"\n      body: \"*\"\n    };\n  };\n}\n```\n\n2. Generate protobuf files and connect to project, then initialize gateway package, [example](./example/simple/cmd/gateway/main.go)\n\n```go\ngw, err := gateway.New(\n    gateway.WithHTTP(server),\n    gateway.WithServiceMapper(mapper), \n    gateway.WithDiscovery(discovery.NewEnvironment().Lookup),\n    gateway.WithGRPCDialTimeout(time.Second*10), \n    gateway.WithServices(map[string]*gateway.GRPCServiceRegistry{\n        \"another\": gateway.NewServiceRegistry(v12.RegisterAnotherHandler),\n    }),\n    gateway.WithGRPCDialOptions([]grpc.DialOption{}...),\n    gateway.WithRouterMiddleware(httpMiddlewares...),\n    gateway.WithGRPCMiddleware(grpcMiddlewares, ),\n)\n\n// register another one service using API\ngw.AddGRPCServiceRegistry(\"some\", gateway.NewServiceRegistry(v1.RegisterSomeHandler))\n\n// and run\nif err = gw.Run(ctx); err != nil {\n    panic(err)\n}\n```\n\n3. Make request\n\n```shell\n$ curl -L http://localhost:1338/some/v1/public/handler_one?code=500\u0026lang=zh\n\n// or POST\n\n$ curl -L -X POST 'http://localhost:1338/some/v1/private/handler_two' -H 'Content-Type: application/json' --data-raw '{}'\n```","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzikwall%2Fgateway","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fzikwall%2Fgateway","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzikwall%2Fgateway/lists"}