Crates.io | roa-tokio |
lib.rs | roa-tokio |
version | 0.5.1 |
source | src |
created_at | 2020-03-20 14:00:08.216104 |
updated_at | 2021-03-29 16:18:30.868998 |
description | tokio-based runtime and acceptor |
homepage | https://github.com/Hexilee/roa/wiki |
repository | https://github.com/Hexilee/roa |
max_upload_size | |
id | 220707 |
size | 11,983 |
This crate provides tokio-based runtime and acceptor for roa.
use roa::http::StatusCode;
use roa::{App, Context};
use roa_tokio::{TcpIncoming, Exec};
use std::error::Error;
async fn end(_ctx: &mut Context) -> roa::Result {
Ok(())
}
#[tokio::main]
async fn main() -> Result<(), Box<dyn Error>> {
let app = App::with_exec((), Exec).end(end);
let incoming = TcpIncoming::bind("127.0.0.1:0")?;
println!("server is listening on {}", incoming.local_addr());
app.accept(incoming).await?;
Ok(())
}