roa-tokio

Crates.ioroa-tokio
lib.rsroa-tokio
version0.5.1
sourcesrc
created_at2020-03-20 14:00:08.216104
updated_at2021-03-29 16:18:30.868998
descriptiontokio-based runtime and acceptor
homepagehttps://github.com/Hexilee/roa/wiki
repositoryhttps://github.com/Hexilee/roa
max_upload_size
id220707
size11,983
xixi (Hexilee)

documentation

https://docs.rs/roa-tokio

README

Stable Test codecov Rust Docs Crate version Download License: MIT

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(())
}
Commit count: 722

cargo fmt