{"id":42428127,"url":"https://github.com/petomalina/xrpc","last_synced_at":"2026-01-28T03:32:24.649Z","repository":{"id":55383050,"uuid":"297618112","full_name":"petomalina/xrpc","owner":"petomalina","description":"Single-port GRPC, WebRPC, HTTP \u0026 Pub/Sub Traffic","archived":false,"fork":false,"pushed_at":"2023-01-30T21:04:27.000Z","size":101,"stargazers_count":7,"open_issues_count":1,"forks_count":1,"subscribers_count":2,"default_branch":"master","last_synced_at":"2024-11-16T03:35:17.198Z","etag":null,"topics":["golang","grpc","grpc-gateway","pubsub","serverless"],"latest_commit_sha":null,"homepage":"","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/petomalina.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-09-22T10:44:38.000Z","updated_at":"2023-04-24T16:57:16.000Z","dependencies_parsed_at":"2023-02-16T11:30:36.204Z","dependency_job_id":null,"html_url":"https://github.com/petomalina/xrpc","commit_stats":null,"previous_names":[],"tags_count":11,"template":false,"template_full_name":null,"purl":"pkg:github/petomalina/xrpc","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/petomalina%2Fxrpc","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/petomalina%2Fxrpc/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/petomalina%2Fxrpc/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/petomalina%2Fxrpc/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/petomalina","download_url":"https://codeload.github.com/petomalina/xrpc/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/petomalina%2Fxrpc/sbom","scorecard":{"id":729467,"data":{"date":"2025-08-11","repo":{"name":"github.com/petomalina/xrpc","commit":"607754fb0d0e08f8593e57d39b3da829d5424b28"},"scorecard":{"version":"v5.2.1-40-gf6ed084d","commit":"f6ed084d17c9236477efd66e5b258b9d4cc7b389"},"score":1.7,"checks":[{"name":"Code-Review","score":0,"reason":"Found 1/30 approved changesets -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project requires human code review before pull requests (aka merge requests) are merged.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#code-review"}},{"name":"Packaging","score":-1,"reason":"packaging workflow not detected","details":["Warn: no GitHub/GitLab publishing workflow detected."],"documentation":{"short":"Determines if the project is published as a package that others can easily download, install, easily update, and uninstall.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#packaging"}},{"name":"Maintained","score":0,"reason":"0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project is \"actively maintained\".","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#maintained"}},{"name":"Token-Permissions","score":-1,"reason":"No tokens found","details":null,"documentation":{"short":"Determines if the project's workflows follow the principle of least privilege.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#token-permissions"}},{"name":"Dangerous-Workflow","score":-1,"reason":"no workflows found","details":null,"documentation":{"short":"Determines if the project's GitHub Action workflows avoid dangerous patterns.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#dangerous-workflow"}},{"name":"Pinned-Dependencies","score":-1,"reason":"no dependencies found","details":null,"documentation":{"short":"Determines if the project has declared and pinned the dependencies of its build process.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#pinned-dependencies"}},{"name":"Binary-Artifacts","score":10,"reason":"no binaries found in the repo","details":null,"documentation":{"short":"Determines if the project has generated executable (binary) artifacts in the source repository.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#binary-artifacts"}},{"name":"CII-Best-Practices","score":0,"reason":"no effort to earn an OpenSSF best practices badge detected","details":null,"documentation":{"short":"Determines if the project has an OpenSSF (formerly CII) Best Practices Badge.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#cii-best-practices"}},{"name":"Security-Policy","score":0,"reason":"security policy file not detected","details":["Warn: no security policy file detected","Warn: no security file to analyze","Warn: no security file to analyze","Warn: no security file to analyze"],"documentation":{"short":"Determines if the project has published a security policy.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#security-policy"}},{"name":"Fuzzing","score":0,"reason":"project is not fuzzed","details":["Warn: no fuzzer integrations found"],"documentation":{"short":"Determines if the project uses fuzzing.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#fuzzing"}},{"name":"License","score":10,"reason":"license file detected","details":["Info: project has a license file: LICENSE:0","Info: FSF or OSI recognized license: MIT License: LICENSE:0"],"documentation":{"short":"Determines if the project has defined a license.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#license"}},{"name":"Signed-Releases","score":-1,"reason":"no releases found","details":null,"documentation":{"short":"Determines if the project cryptographically signs release artifacts.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#signed-releases"}},{"name":"Branch-Protection","score":0,"reason":"branch protection not enabled on development/release branches","details":["Warn: branch protection not enabled for branch 'master'"],"documentation":{"short":"Determines if the default and release branches are protected with GitHub's branch protection settings.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#branch-protection"}},{"name":"SAST","score":0,"reason":"SAST tool is not run on all commits -- score normalized to 0","details":["Warn: 0 commits out of 4 are checked with a SAST tool"],"documentation":{"short":"Determines if the project uses static code analysis.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#sast"}},{"name":"Vulnerabilities","score":0,"reason":"11 existing vulnerabilities detected","details":["Warn: Project is vulnerable to: GO-2022-0969 / GHSA-69cg-p879-7622","Warn: Project is vulnerable to: GO-2022-1144 / GHSA-xrjj-mj9h-534m","Warn: Project is vulnerable to: GO-2023-1571 / GHSA-vvpx-j8f3-3w6h","Warn: Project is vulnerable to: GO-2023-1988 / GHSA-2wrh-6pvc-2jm9","Warn: Project is vulnerable to: GO-2023-2102 / GHSA-4374-p667-p6c8","Warn: Project is vulnerable to: GO-2023-2153 / GHSA-m425-mq94-257g / GHSA-qppj-fm5r-hxr3","Warn: Project is vulnerable to: GO-2024-2687 / GHSA-4v7x-pqxf-cx7m","Warn: Project is vulnerable to: GO-2024-3333","Warn: Project is vulnerable to: GO-2025-3503 / GHSA-qxp5-gwg8-xv66","Warn: Project is vulnerable to: GO-2025-3595 / GHSA-vvgc-356p-c3xw","Warn: Project is vulnerable to: GO-2024-2611 / GHSA-8r3f-844c-mc37"],"documentation":{"short":"Determines if the project has open, known unfixed vulnerabilities.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#vulnerabilities"}}]},"last_synced_at":"2025-08-22T13:58:12.380Z","repository_id":55383050,"created_at":"2025-08-22T13:58:12.380Z","updated_at":"2025-08-22T13:58:12.380Z"},"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28836694,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-28T02:10:51.810Z","status":"ssl_error","status_checked_at":"2026-01-28T02:10:50.806Z","response_time":57,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"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":["golang","grpc","grpc-gateway","pubsub","serverless"],"created_at":"2026-01-28T03:32:24.059Z","updated_at":"2026-01-28T03:32:24.641Z","avatar_url":"https://github.com/petomalina.png","language":"Go","funding_links":[],"categories":["golang"],"sub_categories":[],"readme":"# :rocket: xrpc\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/mod/github.com/petomalina/xrpc)\n[![Go Report Card](https://goreportcard.com/badge/github.com/petomalina/xrpc)](https://goreportcard.com/report/github.com/petomalina/xrpc)\n\n**xrpc** is a small library used to **multiplex GRPC, HTTP \u0026 PubSub traffic on a single port**.\nThe implementation allows multiple servers to act as one. It makes it easy to run e.g. GRPC and grpc-gateway (JSON transcoder)\non a single port in a serverless environment.\n\nYou can run the HTTP, GRPC, Pub/Sub example using this button:\n\n[![Run on Google Cloud](https://deploy.cloud.run/button.svg)](https://deploy.cloud.run?git_repo=github.com/petomalina/xrpc\u0026revision=cloud-run-button)\n\n\n## :wrench: Installation\n\n```\ngo get github.com/petomalina/xrpc/v2\n```\n\n## :book: Guide\n\nCommon use-cases are documented below, but creating new handlers and selectors for the multiplexer\nis as easy as implementing a function.\n\nThe xrpc library works on a concept of *Multiplexer* with multiple *Handlers*. Every Handler has a\ncorresponding set of *Selectors*.\n\n**Multiplexer** is the entry point for the traffic that is being served. You will want the *Multiplexer* to\nserve all incoming traffic to your server.\n\n**Handler** resembles the official `type HandlerFunc func(ResponseWriter, *Request)`, however, it returns bool `type Handler func(ResponseWriter, *Request) bool`.\nThis behavior lets the *Multiplexer* know if the *Handler* is serving the request.\n\n**Selector** is a filter. A Request must pass all Selectors to get handled by a corresponding *Handler*.\n\n### :bookmark: GRPC \u0026 Default HTTP\n\nLet's start with a pure GRPC. This creates a new `EchoService` and registers it with the multiplexer. You can further\nfilter requests coming to the `grpcServer` by adding custom Selectors.\n\n```go\n// create and register the grpc server\ngrpcServer := grpc.NewServer()\nechoSvc := \u0026EchoService{}\napi.RegisterEchoServiceServer(grpcServer, echoSvc)\nreflection.Register(grpcServer)\n\n// make the multiplexer\nmultiplexer.Make(nil,\n    // filters all application/grpc messages into the grpc server\n    multiplexer.GRPCHandler(grpcServer/*, customSelector*/),\n)\n```\n\n\u003e :bulb: Note that all unhandled messages will get \"404 - no handler was fulfilled for your request\"\n\n### :bookmark: GRPC \u0026 HTTP (grpc-gateway)\n\nThis example leverages the [grpc-ecosystem/grpc-gateway ](https://github.com/grpc-ecosystem/grpc-gateway) which transcodes GRPC\nmessages to their JSON equivalents and the other way around. The example is very similar to the GRPC one, however,\nwe'll register the gateway alongside the GRPC handler.\n\n```go\n// create and register the grpc server\ngrpcServer := grpc.NewServer()\nechoSvc := \u0026EchoService{}\napi.RegisterEchoServiceServer(grpcServer, echoSvc)\nreflection.Register(grpcServer)\n\n// create the grpc-gateway server and register to grpc server\ngwmux := runtime.NewServeMux()\nerr = api.RegisterEchoServiceHandlerFromEndpoint(ctx, gwmux, \":\"+os.Getenv(\"PORT\"), []grpc.DialOption{grpc.WithInsecure()})\nif err != nil {\n    logger.Fatal(\"gw: failed to register: %v\", zap.Error(err))\n}\n\n// make the multiplexer\nmultiplexer.Make(nil,\n    // filters all application/grpc messages into the grpc server\n    multiplexer.GRPCHandler(grpcServer),\n    // defaults all other messages into the http multiplexer\n    multiplexer.HTTPHandler(gwmux),\n)\n```\n\nThe full example can be found in the **examples/grpc-http** folder.\n\n### :bookmark: Pub/Sub\n\nLastly, we'll register a Pub/Sub push endpoint that will handle any Pub/Sub messages sent by subscriptions. No need to register\nadditional services, as Pub/Sub messages can be handled by the grpc-gateway.\n\n```go\n// make the multiplexer\nmultiplexer.Make(nil,\n    // filters all application/grpc messages into the grpc server\n    multiplexer.GRPCHandler(grpcServer),\n    // filters all messages with Google Agent into the gwmux and\n    // unpacks the PubSub message\n    multiplexer.PubSubHandler(gwmux),\n+    // defaults all other messages into the http multiplexer\n+    multiplexer.HTTPHandler(gwmux),\n)\n```\n\nThe Handler transfers all Pub/Sub metadata into Request headers, exposing them with a `x-pubsub` prefix:\n```\nmessage.Subscription -\u003e x-pubsub-subscription\nmessage.Message.MessageID -\u003e x-pubsub-message-id\nmessage.Message.PublishTime -\u003e x-pubsub-message-publish-time\n\nmessage.Message.Attributes[key] -\u003e x-pubsub-{key}\n```\n\n### :bookmark: WebRPC (GRPC WebText)\n\nThe xrpc library fully supports a WebRPC implementation through GRPC WebText. The same boilerplate code\ncan be applied for WebRPC support.\n\n```go\ngrpcServer := createGrpcServer(echoSvc)\ngrpcWebServer := grpcweb.WrapServer(grpcServer,\n    grpcweb.WithOriginFunc(func(origin string) bool {\n        return true\n    }),\n)\n\ns.srv = createTestServer(\n    GRPCHandler(grpcServer),\n    GRPCWebTextHandler(grpcWebServer),\n)\n```\n\n### :bookmark: Creating Custom Selectors\n\nThere are times when we need to handle specific cases (e.g. all requests to a certain server must contain some header).\nThe xrpc library has *Selectors* exactly for this use-case. Every handler accepts a list of selectors as the second parameter.\n\n```go\nfunc IsGoogleRobot(r *http.Request) bool {\n\treturn strings.Contains(r.Header.Get(\"User-Agent\"), \"GoogleBot\")\n}\n\nfunc main() {\n    // ...\n\n    multiplexer.Make(nil,\n        multiplexer.HTTPHandler(myRobotHandler, IsGoogleRobot)\n        // register other handlers\n    )\n\n    // ...\n}\n```\n\nThis example creates a new *Selector* that will be executed as a part of the filtering mechanism. Any requests\ncontaining the User-Agent header with \"GoogleBot\" in them will be redirected to the `myBotHandler`.","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpetomalina%2Fxrpc","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpetomalina%2Fxrpc","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpetomalina%2Fxrpc/lists"}