5 releases

0.5.1 Mar 29, 2021
0.5.0 Apr 2, 2020
0.5.0-rc.2 Apr 1, 2020
0.5.0-rc.1 Mar 28, 2020
0.5.0-rc Mar 20, 2020

#668 in #web-framework

22 downloads per month

MIT license

175KB
3.5K SLoC

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(())
}

Dependencies

~13MB
~221K SLoC