[][src]Function actix_web::web::method

pub fn method(method: Method) -> Route

Create route and add method guard.

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

fn main() {
    let app = App::new().service(
        web::resource("/{project_id}")
            .route(web::method(http::Method::GET).to(|| HttpResponse::Ok()))
    );
}

In the above example, one GET route get added:

  • /{project_id}