Function actix_web::web::scope [−][src]
Expand description
Creates scope for common path prefix.
Scopes collect multiple paths under a common path prefix. The scope’s path can contain dynamic path segments.
Examples
In this example, three routes are set up (and will handle any method):
/{project_id}/path1
/{project_id}/path2
/{project_id}/path3
use actix_web::{web, App, HttpResponse};
let app = App::new().service(
web::scope("/{project_id}")
.service(web::resource("/path1").to(|| HttpResponse::Ok()))
.service(web::resource("/path2").to(|| HttpResponse::Ok()))
.service(web::resource("/path3").to(|| HttpResponse::MethodNotAllowed()))
);