[][src]Function actix_web::web::to_async

pub fn to_async<F, I, R>(handler: F) -> Route where
    F: AsyncFactory<I, R>,
    I: FromRequest + 'static,
    R: IntoFuture + 'static,
    R::Item: Responder,
    R::Error: Into<Error>, 

Create a new route and add async handler.

use actix_web::{web, App, HttpResponse, Error};

fn index() -> impl Future<Item=HttpResponse, Error=Error> {
    ok(HttpResponse::Ok().finish())
}

App::new().service(web::resource("/").route(
    web::to_async(index))
);