Skip to main content

method

Function method 

Source
pub fn method<St: State, U: 'static>(method: Method) -> Route<St, U>
Expand description

Create route and add method guard.

use ntex::{http, web};

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

In the above example, one GET route gets added:

  • /{project_id}