{"id":31921873,"url":"https://github.com/rmw-lib/tonic_catch","last_synced_at":"2026-07-16T18:32:56.939Z","repository":{"id":57670171,"uuid":"447441505","full_name":"rmw-lib/tonic_catch","owner":"rmw-lib","description":null,"archived":false,"fork":false,"pushed_at":"2023-06-06T15:21:04.000Z","size":33,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"master","last_synced_at":"2026-07-16T18:32:43.339Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Rust","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/rmw-lib.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}},"created_at":"2022-01-13T02:47:54.000Z","updated_at":"2022-01-13T02:48:17.000Z","dependencies_parsed_at":"2022-09-26T20:40:47.816Z","dependency_job_id":null,"html_url":"https://github.com/rmw-lib/tonic_catch","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"purl":"pkg:github/rmw-lib/tonic_catch","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rmw-lib%2Ftonic_catch","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rmw-lib%2Ftonic_catch/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rmw-lib%2Ftonic_catch/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rmw-lib%2Ftonic_catch/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/rmw-lib","download_url":"https://codeload.github.com/rmw-lib/tonic_catch/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rmw-lib%2Ftonic_catch/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":35555509,"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-07-16T02:00:06.687Z","response_time":83,"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":[],"created_at":"2025-10-13T22:55:10.024Z","updated_at":"2026-07-16T18:32:56.920Z","avatar_url":"https://github.com/rmw-lib.png","language":"Rust","funding_links":[],"categories":[],"sub_categories":[],"readme":"# tonic_catch\n\ncatch any tonic await error convert into Status\n\nfor issue https://github.com/hyperium/tonic/discussions/716#discussioncomment-991404\n\n\nuse example:\n\n```rust\nuse crate::var::evt::Evt;\nuse async_std::channel::Sender;\nuse tonic_catch::{tonic_catch, Result, Error};\nuse log::info;\nuse std::net::SocketAddr;\nuse tonic::{transport::Server, Request, Response};\npub mod proto {\n  tonic::include_proto!(\"proto\");\n}\n\nuse proto::rmw_server::{Rmw, RmwServer};\nuse proto::Url;\n\npub struct RmwSrv {\n  sender: Sender\u003cEvt\u003e,\n}\n\n#[tonic_catch]\nimpl Rmw for RmwSrv {\n  async fn head(\u0026self, request: Request\u003cUrl\u003e) -\u003e Result\u003c()\u003e {\n    let addr = match request.remote_addr() {\n      Some(addr) =\u003e addr.to_string(),\n      None =\u003e String::new(),\n    };\n\n    let url = request.into_inner();\n    println!(\"{:?} {}/{}\", addr, url.addr, url.path);\n\n    self\n      .sender\n      .send(Evt::Head(url.addr.parse()?, url.path))\n      .await?;\n\n    Ok(Response::new(()))\n  }\n}\n\npub async fn run(addr: SocketAddr, sender: Sender\u003cEvt\u003e) -\u003e anyhow::Result\u003c()\u003e {\n  let rmw = RmwServer::new(RmwSrv { sender });\n\n  info!(\"grpc://{}\", addr);\n\n  Server::builder()\n    .accept_http1(true)\n    .add_service(tonic_web::enable(rmw))\n    .serve(addr)\n    .await?;\n\n  Ok(())\n}\n```\n\n\n\n\n## About\n\nThis project is part of the **[rmw.link](//rmw.link)** Code Project .\n\n## 关于\n\n本项目隶属于**人民网络([rmw.link](//rmw.link))** 代码计划。\n\n![人民网络](https://raw.githubusercontent.com/rmw-link/logo/master/rmw.red.bg.svg)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frmw-lib%2Ftonic_catch","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frmw-lib%2Ftonic_catch","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frmw-lib%2Ftonic_catch/lists"}