#web #actix #async #await

nightly actix-web-async-await

Provides a preview of Actix with async/await support

3 unstable releases

✓ Uses Rust 2018 edition

0.2.0 Nov 6, 2018
0.1.1 Oct 26, 2018
0.1.0 Oct 26, 2018

#6 in #await

Download history 35/week @ 2018-12-19 8/week @ 2018-12-26 100/week @ 2019-01-02 93/week @ 2019-01-09 38/week @ 2019-01-16 48/week @ 2019-01-23 28/week @ 2019-01-30 17/week @ 2019-02-06 32/week @ 2019-02-13 8/week @ 2019-02-20 30/week @ 2019-02-27 25/week @ 2019-03-06 4/week @ 2019-03-13 38/week @ 2019-03-20 17/week @ 2019-03-27

109 downloads per month



Actix Web Async/Await Preview

This crate provides a preview of Actix with async/await support.


To use this crate, you need to start with a Rust 2018 edition crate.

Add this to your Cargo.toml:

# In the `[package]` section
edition = "2018"

# In the `[dependencies]` section
actix-web-async-await = "0.1.0"

Then, get started. Here is the headline Actix example with the addition that it asynchronously delays the request by 2 seconds.

The general idea is to wrap your async fn handlers in compat. There are compat2, compat3, etc. for routes taking multiple arguments.

#![feature(await_macro, futures_api, async_await)]

use actix_web::{http, server, App, Path, Responder, Result};
use actix_web_async_await::{await, compat};
use std::time::{Instant, Duration};
use tokio::timer::Delay;

async fn index(info: Path<(u32, String)>) -> Result<impl Responder> {
    // Wait 2s
    await!(Delay::new(Instant::now() + Duration::from_secs(2)))?;

    // Proceed with normal response
    Ok(format!("Hello {}! id:{}", info.1, info.0))

fn main() {
        || App::new()
            .route("/{id}/{name}/index.html", http::Method::GET, compat(index)))

Note that your async fn handlers must return Result currently. This is both because they are being converted to futures v0.1 which requires an error type and because nearly the entire rust async ecosystem uses futures v0.1 which is going to have errors on all futures. An error-less compat could be provided if the support is wanted.


Licensed under either of

at your option.


Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.


~293K SLoC