Skip to content

Commit

Permalink
Rename 'Rocket::configure()' to 'reconfigure'.
Browse files Browse the repository at this point in the history
  • Loading branch information
SergioBenitez committed Apr 25, 2024
1 parent b340853 commit 49176e0
Show file tree
Hide file tree
Showing 10 changed files with 37 additions and 37 deletions.
2 changes: 1 addition & 1 deletion core/lib/src/local/asynchronous/response.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ use crate::{Request, Response};
/// #[launch]
/// fn rocket() -> _ {
/// rocket::build().mount("/", routes![hello_world])
/// # .configure(rocket::Config::debug_default())
/// # .reconfigure(rocket::Config::debug_default())
/// }
///
/// # async fn read_body_manually() -> io::Result<()> {
Expand Down
2 changes: 1 addition & 1 deletion core/lib/src/local/blocking/response.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ use super::Client;
/// #[launch]
/// fn rocket() -> _ {
/// rocket::build().mount("/", routes![hello_world])
/// # .configure(rocket::Config::debug_default())
/// # .reconfigure(rocket::Config::debug_default())
/// }
///
/// # fn read_body_manually() -> io::Result<()> {
Expand Down
2 changes: 1 addition & 1 deletion core/lib/src/local/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ macro_rules! pub_client_impl {
.merge((config::Config::LOG_LEVEL, config::LogLevel::Debug))
.select(config::Config::DEBUG_PROFILE);

Self::tracked(rocket.configure(figment)) $(.$suffix)?
Self::tracked(rocket.reconfigure(figment)) $(.$suffix)?
}

/// Returns a reference to the `Rocket` this client is creating requests
Expand Down
6 changes: 3 additions & 3 deletions core/lib/src/rocket.rs
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,7 @@ impl Rocket<Build> {
/// .merge((Config::IDENT, "Example"));
///
/// let rocket = rocket::custom(&config)
/// .configure(figment)
/// .reconfigure(figment)
/// .ignite().await?;
///
/// assert_eq!(rocket.config().ident.as_str(), Some("Example"));
Expand All @@ -238,7 +238,7 @@ impl Rocket<Build> {
/// # });
/// ```
#[must_use]
pub fn configure<T: Provider>(mut self, provider: T) -> Self {
pub fn reconfigure<T: Provider>(mut self, provider: T) -> Self {
self.figment = Figment::from(provider);
self
}
Expand Down Expand Up @@ -522,7 +522,7 @@ impl Rocket<Build> {
/// #[rocket::main]
/// async fn main() -> Result<(), rocket::Error> {
/// let rocket = rocket::build()
/// # .configure(rocket::Config::debug_default())
/// # .reconfigure(rocket::Config::debug_default())
/// .attach(AdHoc::on_ignite("Manage State", |rocket| async move {
/// rocket.manage(String::from("managed string"))
/// }));
Expand Down
4 changes: 2 additions & 2 deletions core/lib/src/sentinel.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ use crate::{Rocket, Ignite};
///
/// # use rocket::{Config, error::ErrorKind};
/// # rocket::async_test(async {
/// # let result = rocket().configure(Config::debug_default()).ignite().await;
/// # let result = rocket().reconfigure(Config::debug_default()).ignite().await;
/// # assert!(matches!(result.unwrap_err().kind(), ErrorKind::SentinelAborts(..)));
/// # })
/// ```
Expand Down Expand Up @@ -76,7 +76,7 @@ use crate::{Rocket, Ignite};
///
/// # use rocket::{Config, error::ErrorKind};
/// # rocket::async_test(async {
/// # rocket().configure(Config::debug_default()).ignite().await.unwrap();
/// # rocket().reconfigure(Config::debug_default()).ignite().await.unwrap();
/// # })
/// ```
///
Expand Down
26 changes: 13 additions & 13 deletions core/lib/tests/sentinel.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,15 @@ fn one_state<'r>(_three: &'r State<u8>, s: &'r str) -> &'r str { s }
#[async_test]
async fn state_sentinel_works() {
let err = rocket::build()
.configure(Config::debug_default())
.reconfigure(Config::debug_default())
.mount("/", routes![two_states])
.ignite().await
.unwrap_err();

assert!(matches!(err.kind(), SentinelAborts(vec) if vec.len() == 2));

let err = rocket::build()
.configure(Config::debug_default())
.reconfigure(Config::debug_default())
.mount("/", routes![two_states])
.manage(String::new())
.ignite().await
Expand All @@ -26,7 +26,7 @@ async fn state_sentinel_works() {
assert!(matches!(err.kind(), SentinelAborts(vec) if vec.len() == 1));

let err = rocket::build()
.configure(Config::debug_default())
.reconfigure(Config::debug_default())
.mount("/", routes![two_states])
.manage(1 as u32)
.ignite().await
Expand All @@ -35,7 +35,7 @@ async fn state_sentinel_works() {
assert!(matches!(err.kind(), SentinelAborts(vec) if vec.len() == 1));

let result = rocket::build()
.configure(Config::debug_default())
.reconfigure(Config::debug_default())
.mount("/", routes![two_states])
.manage(String::new())
.manage(1 as u32)
Expand All @@ -44,31 +44,31 @@ async fn state_sentinel_works() {
assert!(result.is_ok());

let err = rocket::build()
.configure(Config::debug_default())
.reconfigure(Config::debug_default())
.mount("/", routes![one_state])
.ignite().await
.unwrap_err();

assert!(matches!(err.kind(), SentinelAborts(vec) if vec.len() == 1));

let result = rocket::build()
.configure(Config::debug_default())
.reconfigure(Config::debug_default())
.mount("/", routes![one_state])
.manage(1 as u8)
.ignite().await;

assert!(result.is_ok());

let err = rocket::build()
.configure(Config::debug_default())
.reconfigure(Config::debug_default())
.mount("/", routes![one_state, two_states])
.ignite().await
.unwrap_err();

assert!(matches!(err.kind(), SentinelAborts(vec) if vec.len() == 3));

let err = rocket::build()
.configure(Config::debug_default())
.reconfigure(Config::debug_default())
.mount("/", routes![one_state, two_states])
.manage(1 as u32)
.ignite().await
Expand All @@ -77,7 +77,7 @@ async fn state_sentinel_works() {
assert!(matches!(err.kind(), SentinelAborts(vec) if vec.len() == 2));

let err = rocket::build()
.configure(Config::debug_default())
.reconfigure(Config::debug_default())
.mount("/", routes![one_state, two_states])
.manage(1 as u8)
.ignite().await
Expand All @@ -86,7 +86,7 @@ async fn state_sentinel_works() {
assert!(matches!(err.kind(), SentinelAborts(vec) if vec.len() == 2));

let err = rocket::build()
.configure(Config::debug_default())
.reconfigure(Config::debug_default())
.mount("/", routes![one_state, two_states])
.manage(1 as u32)
.manage(1 as u8)
Expand All @@ -96,7 +96,7 @@ async fn state_sentinel_works() {
assert!(matches!(err.kind(), SentinelAborts(vec) if vec.len() == 1));

let result = rocket::build()
.configure(Config::debug_default())
.reconfigure(Config::debug_default())
.mount("/", routes![one_state, two_states])
.manage(1 as u32)
.manage(1 as u8)
Expand Down Expand Up @@ -128,15 +128,15 @@ fn with_data(_data: Data) {}
#[async_test]
async fn data_sentinel_works() {
let err = rocket::build()
.configure(Config::debug_default())
.reconfigure(Config::debug_default())
.mount("/", routes![with_data])
.ignite().await
.unwrap_err();

assert!(matches!(err.kind(), SentinelAborts(vec) if vec.len() == 1));

let result = rocket::build()
.configure(Config::debug_default())
.reconfigure(Config::debug_default())
.mount("/", routes![with_data])
.manage(Data)
.ignite().await;
Expand Down
4 changes: 2 additions & 2 deletions core/lib/tests/shutdown-fairings.rs
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ async fn async_slow_shutdown_doesnt_elongate_grace() {

let rocket = rocket::build()
.manage(Flags::default())
.configure(config)
.reconfigure(config)
.attach(AdHoc::on_shutdown("Slow Shutdown", |rocket| Box::pin(async move {
tokio::time::sleep(std::time::Duration::from_secs(4)).await;
let flags = rocket.state::<Flags>().unwrap();
Expand Down Expand Up @@ -141,7 +141,7 @@ fn background_tasks_dont_prevent_terminate() {
config.shutdown.grace = 1;
config.shutdown.mercy = 1;

let rocket = rocket::build().configure(config).mount("/", routes![index]);
let rocket = rocket::build().reconfigure(config).mount("/", routes![index]);

let client = Client::debug(rocket).unwrap();
let response = client.get("/").dispatch();
Expand Down
4 changes: 2 additions & 2 deletions docs/guide/09-testing.md
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ testing: we _want_ our tests to panic when something goes wrong.
```rust
# #[rocket::launch]
# fn rocket() -> _ {
# rocket::build().configure(rocket::Config::debug_default())
# rocket::build().reconfigure(rocket::Config::debug_default())
# }
# use rocket::local::blocking::Client;

Expand All @@ -194,7 +194,7 @@ application's response:
# use rocket::uri;
# #[rocket::launch]
# fn rocket() -> _ {
# rocket::build().configure(rocket::Config::debug_default())
# rocket::build().reconfigure(rocket::Config::debug_default())
# }

# #[rocket::get("/")]
Expand Down
2 changes: 1 addition & 1 deletion examples/tls/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ fn validate_profiles(profiles: &[&str]) {
};

let figment = Config::figment().merge(config).select(profile);
let client = Client::tracked_secure(super::rocket().configure(figment)).unwrap();
let client = Client::tracked_secure(super::rocket().reconfigure(figment)).unwrap();
let response = client.get("/").dispatch();
assert_eq!(response.into_string().unwrap(), "Hello, world!");

Expand Down
22 changes: 11 additions & 11 deletions testbench/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,28 +34,28 @@ static TLS_CONFIG: &str = r#"
trait RocketExt {
fn default() -> Self;
fn tls_default() -> Self;
fn configure_with_toml(self, toml: &str) -> Self;
fn reconfigure_with_toml(self, toml: &str) -> Self;
}

impl RocketExt for Rocket<Build> {
fn default() -> Self {
rocket::build().configure_with_toml(DEFAULT_CONFIG)
rocket::build().reconfigure_with_toml(DEFAULT_CONFIG)
}

fn tls_default() -> Self {
rocket::build()
.configure_with_toml(DEFAULT_CONFIG)
.configure_with_toml(TLS_CONFIG)
.reconfigure_with_toml(DEFAULT_CONFIG)
.reconfigure_with_toml(TLS_CONFIG)
}

fn configure_with_toml(self, toml: &str) -> Self {
fn reconfigure_with_toml(self, toml: &str) -> Self {
use rocket::figment::{Figment, providers::{Format, Toml}};

let toml = toml.replace("{ROCKET}", rocket::fs::relative!("../"));
let config = Figment::from(self.figment())
.merge(Toml::string(&toml).nested());

self.configure(config)
self.reconfigure(config)
}
}

Expand Down Expand Up @@ -139,7 +139,7 @@ fn tls_info() -> Result<()> {

let server = Server::spawn((), |(token, _)| {
let rocket = rocket::build()
.configure_with_toml(TLS_CONFIG)
.reconfigure_with_toml(TLS_CONFIG)
.mount("/", routes![hello_world]);

token.with_launch(rocket, |rocket| {
Expand Down Expand Up @@ -229,7 +229,7 @@ fn test_mtls(mandatory: bool) -> Result<()> {
}

Rocket::tls_default()
.configure_with_toml(&mtls_config)
.reconfigure_with_toml(&mtls_config)
.mount("/", routes![hello, hi])
})?;

Expand Down Expand Up @@ -318,7 +318,7 @@ fn sni_resolver() -> Result<()> {
#[get("/")] fn index() { }

Rocket::default()
.configure_with_toml(SNI_TLS_CONFIG)
.reconfigure_with_toml(SNI_TLS_CONFIG)
.mount("/", routes![index])
.attach(SniResolver::fairing())
}?;
Expand Down Expand Up @@ -348,7 +348,7 @@ fn sni_resolver() -> Result<()> {

fn tcp_unix_listener_fail() -> Result<()> {
let server = spawn! {
Rocket::default().configure_with_toml("[default]\naddress = 123")
Rocket::default().reconfigure_with_toml("[default]\naddress = 123")
};

if let Err(Error::Liftoff(stdout, _)) = server {
Expand All @@ -359,7 +359,7 @@ fn tcp_unix_listener_fail() -> Result<()> {
}

let server = Server::spawn((), |(token, _)| {
let rocket = Rocket::default().configure_with_toml("[default]\naddress = \"unix:foo\"");
let rocket = Rocket::default().reconfigure_with_toml("[default]\naddress = \"unix:foo\"");
token.launch_with::<TcpListener>(rocket)
});

Expand Down

0 comments on commit 49176e0

Please sign in to comment.