pub fn configure<F>(mut self, f: F) -> Self
    where
        F: FnOnce(&mut ServiceConfig),
    {
        let mut cfg = ServiceConfig::new();
        f(&mut cfg);
        self.services.extend(cfg.services);
        self.external.extend(cfg.external);

        self.app_data
            .get_or_insert_with(Extensions::new)
            .extend(cfg.app_data);
        self
    }
/// Run external configuration as part of the scope building
/// process
///
/// This function is useful for moving parts of configuration to a
/// different module or even library. For example,
/// some of the resource's configuration could be moved to different module.
///
/// ```rust
/// # extern crate actix_web;
/// use actix_web::{web, middleware, App, HttpResponse};
///
/// // this function could be located in different module
/// fn config(cfg: &mut web::ServiceConfig) {
///     cfg.service(web::resource("/test")
///         .route(web::get().to(|| HttpResponse::Ok()))
///         .route(web::head().to(|| HttpResponse::MethodNotAllowed()))
///     );
/// }
///
/// fn main() {
///     let app = App::new()
///         .wrap(middleware::Logger::default())
///         .service(
///             web::scope("/api")
///                 .configure(config)
///         )
///         .route("/index.html", web::get().to(|| HttpResponse::Ok()));
/// }
/// ```
Run external configuration as part of the scope building
process

This function is useful for moving parts of configuration to a
different module or even library. For example,
some of the resource's configuration could be moved to different module.


Run external configuration as part of the scope building process This function is useful for moving parts of configuration to a different module or even library . For example some of the resource ' s configuration could be moved to different module .
pub fn configure<F>(mut self, f: F) -> Self
    where
        F: FnOnce(&mut ServiceConfig),
    {
        let mut cfg = ServiceConfig::new();
        f(&mut cfg);
        self.services.extend(cfg.services);
        self.external.extend(cfg.external);
        self.app_data
            .get_or_insert_with(Extensions::new)
            .extend(cfg.app_data);
        self
    }
pub fn configure < F > ( mut self , f : F ) -> Self where F : FnOnce ( & mut ServiceConfig ) , { let mut cfg = ServiceConfig :: new ( ) ; f ( & mut cfg ) ; self . services . extend ( cfg . services ) ; self . external . extend ( cfg . external ) ; self . app_data . get_or_insert_with ( Extensions :: new ) . extend ( cfg . app_data ) ; self }
Run external configuration as part of the scope building
process
Run external configuration as part of the scope building process
mut self
f
F
mut self
f
F
extern crate actix_web;
use actix_web::{web, middleware, App, HttpResponse}.

this function could be located in different module
fn config(cfg: &mut web::ServiceConfig) {
cfg.service(web::resource("/test")
.route(web::get().to(|| HttpResponse::Ok()))
.route(web::head().to(|| HttpResponse::MethodNotAllowed()))
);
}

fn main() {
let app = App::new()
.wrap(middleware::Logger::default())
.service(
web::scope("/api")
.configure(config)
)
.route("/index.html", web::get().to(|| HttpResponse::Ok()));
}
```
use actix_web :: { web middleware App HttpResponse } . this function could be located in different module fn config ( cfg : &mut web :: ServiceConfig ) { cfg . service ( web :: resource ( " / test " ) . route ( web :: get () . to ( || HttpResponse :: Ok () )) . route ( web :: head () . to ( || HttpResponse :: MethodNotAllowed () )) ) ; } fn main () { let app = App :: new () . wrap ( middleware :: Logger :: default () ) . service ( web :: scope ( " / api " ) . configure ( config ) ) . route ( " / index . html " web :: get () . to ( || HttpResponse :: Ok () )) ; } ` ` `