catch any tonic await error convert into Status
for issue https://github.com/hyperium/tonic/discussions/716#discussioncomment-991404
use example:
```rust use crate::var::evt::Evt; use asyncstd::channel::Sender; use toniccatch::{toniccatch, Result, Error}; use log::info; use std::net::SocketAddr; use tonic::{transport::Server, Request, Response}; pub mod proto { tonic::includeproto!("proto"); }
use proto::rmw_server::{Rmw, RmwServer}; use proto::Url;
pub struct RmwSrv {
sender: Sender
impl Rmw for RmwSrv {
async fn head(&self, request: Request
let url = request.into_inner();
println!("{:?} {}/{}", addr, url.addr, url.path);
self
.sender
.send(Evt::Head(url.addr.parse()?, url.path))
.await?;
Ok(Response::new(()))
} }
pub async fn run(addr: SocketAddr, sender: Sender
info!("grpc://{}", addr);
Server::builder() .accepthttp1(true) .addservice(tonic_web::enable(rmw)) .serve(addr) .await?;
Ok(()) } ```
This project is part of the rmw.link Code Project .
本项目隶属于人民网络(rmw.link) 代码计划。