{"id":23219482,"url":"https://github.com/vallahaye/connect-gateway","last_synced_at":"2025-09-04T07:07:10.548Z","repository":{"id":153226718,"uuid":"611894427","full_name":"vallahaye/connect-gateway","owner":"vallahaye","description":"gRPC-Gateway to Connect local binding generator","archived":false,"fork":false,"pushed_at":"2024-11-11T15:49:03.000Z","size":60,"stargazers_count":10,"open_issues_count":1,"forks_count":1,"subscribers_count":1,"default_branch":"main","last_synced_at":"2024-11-12T23:35:12.708Z","etag":null,"topics":["connect","go","golang","grpc-gateway","protobuf","protocol-buffers"],"latest_commit_sha":null,"homepage":"https://go.vallahaye.net/connect-gateway","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/vallahaye.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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2023-03-09T19:02:21.000Z","updated_at":"2024-10-12T10:52:16.000Z","dependencies_parsed_at":"2023-12-31T15:24:03.845Z","dependency_job_id":"7a76acd4-5235-4206-84ab-430d0af75219","html_url":"https://github.com/vallahaye/connect-gateway","commit_stats":null,"previous_names":[],"tags_count":16,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vallahaye%2Fconnect-gateway","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vallahaye%2Fconnect-gateway/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vallahaye%2Fconnect-gateway/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vallahaye%2Fconnect-gateway/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/vallahaye","download_url":"https://codeload.github.com/vallahaye/connect-gateway/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":230343998,"owners_count":18211805,"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":["connect","go","golang","grpc-gateway","protobuf","protocol-buffers"],"created_at":"2024-12-18T21:34:21.013Z","updated_at":"2024-12-18T21:34:21.760Z","avatar_url":"https://github.com/vallahaye.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Connect-Gateway\n\n[![Go Reference](https://pkg.go.dev/badge/go.vallahaye.net/connect-gateway.svg)](https://pkg.go.dev/go.vallahaye.net/connect-gateway)\n[![Go Report Card](https://goreportcard.com/badge/go.vallahaye.net/connect-gateway)](https://goreportcard.com/report/go.vallahaye.net/connect-gateway)\n\nThe Connect-Gateway introduces direct binding from [gRPC-Gateway](https://grpc-ecosystem.github.io/grpc-gateway/) local handlers to [Connect](https://connectrpc.com/) service handlers. It addresses the recurring request to support Google API HTTP annotations in Connect:\n\n- [Service option for Connect HTTP path #468](https://github.com/connectrpc/connect-go/issues/468)\n- [`google.api.Http` annotation support #274](https://github.com/connectrpc/connect-go/issues/274)\n\nWe provide a complete solution for the two to communicate seamlessly through simple function calls, without relying on network communications. All of which is done by reusing as much of the code from both projects as possible and mimicking the [connect-go](https://github.com/connectrpc/connect-go) implementation, i.e. reducing code generation as much as possible, with most of the logic being provided in a library.\n\n### Features\n\n- Unary calls support\n- Connect interceptors support\n- Bidirectional gRPC metadata transmission\n- Connect errors to gRPC errors convertion\n\n### Limitations\n\n- No support for streaming calls as [it is not yet supported by the gRPC-Gateway's \"in-process\" transport mode](https://github.com/grpc-ecosystem/grpc-gateway/blob/main/protoc-gen-grpc-gateway/internal/gengateway/template.go#L621)\n- Uninitialized [Request.Peer](https://pkg.go.dev/connectrpc.com/connect#Request.Peer) and [Request.Spec](https://pkg.go.dev/connectrpc.com/connect#Request.Spec) properties on Connect requests as it cannot be set externally\n\n## Getting started\n\n### Install tools\n\nFirst, we'll need to install the `protoc-gen-connect-gateway` code generation tool:\n\n```\n$ go install go.vallahaye.net/connect-gateway/cmd/protoc-gen-connect-gateway@latest\n```\n\nMake sure that the binary is accessible from your `PATH`:\n\n```\n$ which protoc-gen-connect-gateway\n/go/bin/protoc-gen-connect-gateway\n```\n\n### Generate code\n\nAssuming [Buf code generation](https://buf.build/docs/generate/overview) is already configured for [Protocol Buffers](https://buf.build/protocolbuffers/go), [gRPC](https://buf.build/grpc/go), the [gRPC-Gateway](https://buf.build/grpc-ecosystem/gateway) and [Connect](https://buf.build/connectrpc/go), add the Connect-Gateway plugin to your `buf.gen.yaml` file:\n\n```yaml\nversion: v2\nplugins:\n  - local: protoc-gen-connect-gateway\n    out: gen\n    opt: paths=source_relative\n```\n\nThen run the `buf generate` command to generate code.\n\nApplying this configuration to the [Connect Greet service example](https://connectrpc.com/docs/go/getting-started/#define-a-service) produces the following output, where the `greet.connect.gw.go` file contains the adapter to interface the gRPC gateway with the Connect server handlers for the `GreetService`:\n\n```shell\ngen\n└── greet\n    └── v1\n        ├── greet_grpc.pb.go\n        ├── greet.pb.go\n        ├── greet.pb.gw.go\n        └── greetv1connect\n            ├── greet.connect.go\n            └── greet.connect.gw.go\n```\n\n### Implement handler\n\nWe use the code generated by instantiating a [gRPC-Gateway router](https://pkg.go.dev/github.com/grpc-ecosystem/grpc-gateway/v2/runtime#ServeMux) and registering Connect server handlers with it, using the helper function generated by the Connect-Gateway plugin:\n\n```go\npackage main\n\nimport (\n    \"context\"\n    \"fmt\"\n    \"log\"\n    \"net/http\"\n\n    \"connectrpc.com/connect\"\n    \"github.com/grpc-ecosystem/grpc-gateway/v2/runtime\"\n\n    greetv1 \"example/gen/greet/v1\"\n    \"example/gen/greet/v1/greetv1connect\"\n)\n\ntype GreetServer struct{}\n\nfunc (s *GreetServer) Greet(\n    ctx context.Context,\n    req *connect.Request[greetv1.GreetRequest],\n) (*connect.Response[greetv1.GreetResponse], error) {\n    log.Println(\"Request headers: \", req.Header())\n    res := connect.NewResponse(\u0026greetv1.GreetResponse{\n        Greeting: fmt.Sprintf(\"Hello, %s!\", req.Msg.Name),\n    })\n    res.Header().Set(\"Greet-Version\", \"v1\")\n    return res, nil\n}\n\nfunc main() {\n    greeter := \u0026GreetServer{}\n    mux := runtime.NewServeMux()\n    greetv1connect.RegisterGreetServiceHandlerGatewayServer(mux, greeter)\n    http.ListenAndServe(\":8080\", mux)\n}\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvallahaye%2Fconnect-gateway","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fvallahaye%2Fconnect-gateway","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvallahaye%2Fconnect-gateway/lists"}