pub fn to<St, In, F, Args>(handler: F) -> Route<St, In>where
St: State,
In: 'static,
F: Handler<St, Args> + 'static,
Args: FromRequest<St> + 'static,
Args::Error: WebResponseError<St, St::Error>,Expand description
Create an unguarded route with a handler.
The handler receives values produced by request extractors and returns a
type implementing Responder. If extraction fails, the
error is converted into a response and the handler is not called.
The returned route has no method or custom guards, so it matches every
request considered by its resource. Add guards before the handler with
helpers such as get() or with Route::guard().
use ntex::web;
async fn show_user(id: web::types::Path<u32>) -> String {
format!("User {}", id.into_inner())
}
web::App::default().service(
web::resource("/users/{id}").route(web::to(show_user))
);