From d9938d490913ddd92d93fe27ab7317755fca1cf9 Mon Sep 17 00:00:00 2001 From: mibac138 <5672750+mibac138@users.noreply.github.com> Date: Sat, 13 Feb 2021 14:40:51 +0100 Subject: [PATCH] Add `ServiceConfig::configure` --- CHANGES.md | 4 +++- src/config.rs | 11 +++++++++++ 2 files changed, 14 insertions(+), 1 deletion(-) 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).