Crates.io | poem-grpc |
lib.rs | poem-grpc |
version | 0.5.2 |
source | src |
created_at | 2022-08-05 10:58:07.62843 |
updated_at | 2024-11-20 06:32:59.411847 |
description | GRPC support for Poem. |
homepage | https://github.com/poem-web/poem |
repository | https://github.com/poem-web/poem |
max_upload_size | |
id | 639265 |
size | 155,420 |
use poem::{listener::TcpListener, Server};
use poem_grpc::{Request, Response, RouteGrpc, Status};
poem_grpc::include_proto!("helloworld");
struct GreeterService;
impl Greeter for GreeterService {
async fn say_hello(
&self,
request: Request<HelloRequest>,
) -> Result<Response<HelloReply>, Status> {
let reply = HelloReply {
message: format!("Hello {}!", request.into_inner().name),
};
Ok(Response::new(reply))
}
}
#[tokio::main]
async fn main() -> Result<(), std::io::Error> {
let route = RouteGrpc::new().add_service(GreeterServer::new(GreeterService));
Server::new(TcpListener::bind("0.0.0.0:3000"))
.run(route)
.await
}
This crate uses #![forbid(unsafe_code)]
to ensure everything is implemented in 100% Safe Rust.
The minimum supported Rust version for this crate is 1.81.0
.
:balloon: Thanks for your help improving the project! We are so happy to have you!
Licensed under either of
Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in Poem by you, shall be licensed as Apache, without any additional terms or conditions.