Crates.io | poem-grpc |
lib.rs | poem-grpc |
version | 0.5.1 |
source | src |
created_at | 2022-08-05 10:58:07.62843 |
updated_at | 2024-09-12 05:29:50.065821 |
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 | 154,717 |
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.76.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.