{"id":18993053,"url":"https://github.com/bakins/grpc-transcode-handler","last_synced_at":"2025-02-21T11:28:09.143Z","repository":{"id":136985146,"uuid":"186500218","full_name":"bakins/grpc-transcode-handler","owner":"bakins","description":"Experimental Go HTTP server handler for transcoding HTTP+JSON requests to gRPC.","archived":false,"fork":false,"pushed_at":"2025-02-04T18:14:23.000Z","size":240,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-02-04T19:23:43.661Z","etag":null,"topics":["go","golang","grpc","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":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/bakins.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":"2019-05-13T21:47:25.000Z","updated_at":"2025-02-04T18:14:19.000Z","dependencies_parsed_at":null,"dependency_job_id":"dfc4c320-2242-4338-8ef9-298163aec617","html_url":"https://github.com/bakins/grpc-transcode-handler","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/bakins%2Fgrpc-transcode-handler","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bakins%2Fgrpc-transcode-handler/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bakins%2Fgrpc-transcode-handler/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bakins%2Fgrpc-transcode-handler/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/bakins","download_url":"https://codeload.github.com/bakins/grpc-transcode-handler/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":240004939,"owners_count":19732661,"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-go"],"created_at":"2024-11-08T17:19:43.242Z","updated_at":"2025-02-21T11:28:09.076Z","avatar_url":"https://github.com/bakins.png","language":"Go","readme":"# grpc-transcode-handler\n\nGo HTTP server handler for transcoding HTTP+JSON requests to gRPC.\n\n[![GoDoc](https://godoc.org/github.com/bakins/grpc-transcode-handler?status.svg)](https://godoc.org/github.com/bakins/grpc-transcode-handler)\n\n## Why?\n\nI was doing a side project with [grpc-gateway](https://github.com/grpc-ecosystem/grpc-gateway) and decided to try something similar without code generation that would run in-process with the \"real\" gRPC server.\n\nAlso, for whatever reason, I like doing silly experiments with gRPC in Go.\n\n## What is it?\n\n`grpc-transcode-handler` is a Go package that allows one to create an HTTP handler that will transcode HTTP+JSON\nto gRPC in-process.\n\n`grpc-transcode-handler` does not allow one to override URLs for services.  The URL path will be the same as it is in gRPC. For example,\nin the [helloworld](https://github.com/grpc/grpc-go/blob/master/examples/helloworld/helloworld/helloworld.proto) example, all methods in the\n`helloworld` namespace for service `Greeter` would be at HTTP path `/helloworld.Greeter`, so the `SayHello` method would be at `/helloworld.Greeter/SayHello`.  If you run the [example server](./example/server) in this project, you could use curl to make a request like:\n\n```\ncurl -XPOST -H \"Content-Type: application/json\" -d '{ \"name\": \"world\"}' -sv http://localhost:9090/helloworld.Greeter/SayHello\n```\n\n## How it works?\n\nSee the [example server](./example/server/server.go) for example usage.\n\nThe general flow while writing a server is:\n\n* create a handler\n* register a grpc service on the handler. You may also register this service on another \"real\" gRPC server.\n* start the handler - this starts an in process gRPC server for the transcoding.\n\nWhile running, the handler when it receives an HTTP request will\n\n* Read the request body\n* add grpc framing - the body is not processed in any way, yes\n* send the grpc request over an [in memory listner](https://github.com/akutz/memconn) to the handlers internal gRPC server\n* the internal gRPC server will unmarshal the JSON body to the appropriate structs and call your service handlers\n* the internal gRPC server will marshal responses as JSON (with the proper gRPC framing) and send them over the in memory connection\n* The client will receieve the response, send approriate HTTP headers, and send response to original client\n\nLike [grpc-gateway](https://github.com/grpc-ecosystem/grpc-gateway), `grpc-transcode-handler` handles streamed responses by outputting newline separated JSON. Streaming requests are not supported.\n\n## Inspired by\n\n* https://github.com/mwitkow/grpc-proxy - grpc passthrough proxy\n* https://github.com/grpc-ecosystem/grpc-gateway\n\n## License\n\nsee [LICENSE](./LICENSE)\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbakins%2Fgrpc-transcode-handler","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbakins%2Fgrpc-transcode-handler","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbakins%2Fgrpc-transcode-handler/lists"}