[−][src]Function actix_web::web::to_async
pub fn to_async<F, I, R, P: 'static>(handler: F) -> Route<P> where
F: AsyncFactory<I, R>,
I: FromRequest<P> + 'static,
R: IntoFuture + 'static,
R::Item: Into<Response>,
R::Error: Into<Error>,
Create a new route and add async handler.
use actix_web::{web, App, HttpResponse, Error}; fn index() -> impl futures::Future<Item=HttpResponse, Error=Error> { futures::future::ok(HttpResponse::Ok().finish()) } App::new().service(web::resource("/").route( web::to_async(index)) );