diff --git a/CHANGES.md b/CHANGES.md index 743f5066b..39de18371 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -1,11 +1,13 @@ # Changes ## Unreleased - 2021-xx-xx +### Added +* Added `ServiceConfig::configure` to allow easy nesting of configuration. [#1988] ### Changed * Feature `cookies` is now optional and enabled by default. [#1981] [#1981]: https://github.com/actix/actix-web/pull/1981 - +[#1988]: https://github.com/actix/actix-web/pull/1988 ## 4.0.0-beta.3 - 2021-02-10 * Update `actix-web-codegen` to `0.5.0-beta.1`. diff --git a/src/config.rs b/src/config.rs index bd9a25c6f..1d8513cdc 100644 --- a/src/config.rs +++ b/src/config.rs @@ -199,6 +199,17 @@ impl ServiceConfig { self } + /// Run external configuration as part of the application building process + /// + /// Counterpart to [`App::configure()`](crate::App::configure) that allows for easy nesting. + pub fn configure(&mut self, f: F) -> &mut Self + where + F: FnOnce(&mut ServiceConfig), + { + f(self); + self + } + /// Configure route for a specific path. /// /// Counterpart to [`App::route()`](crate::App::route).