Function actix_web::web::to

source ·
pub fn to<F, Args>(handler: F) -> Routewhere
    F: Handler<Args>,
    Args: FromRequest + 'static,
    F::Output: Responder + 'static,
Expand description

Creates a new any-method route with handler.

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

async fn index() -> impl Responder {
   HttpResponse::Ok()
}

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