From 41386cfb78d7724f9acc39821337285d604444e8 Mon Sep 17 00:00:00 2001 From: Sergio Benitez Date: Wed, 19 Apr 2017 02:23:06 -0700 Subject: [PATCH] Display the port that was resolved, not configured. --- Cargo.toml | 3 +++ lib/Cargo.toml | 7 ++++++- lib/src/error.rs | 7 +++++++ lib/src/rocket.rs | 9 +++++++-- 4 files changed, 23 insertions(+), 3 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 97ae1a1f..858417c0 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -39,3 +39,6 @@ members = [ "examples/raw_sqlite", "examples/hello_tls", ] + +[replace] +"hyper:0.10.8" = { git = 'https://github.com/SergioBenitez/hyper', branch = "0.10.x" } diff --git a/lib/Cargo.toml b/lib/Cargo.toml index 90b654a3..88c1161e 100644 --- a/lib/Cargo.toml +++ b/lib/Cargo.toml @@ -22,7 +22,6 @@ tls = ["rustls", "hyper-rustls"] term-painter = "0.2" log = "0.3" url = "1" -hyper = { version = "0.10.4", default-features = false } toml = { version = "0.2", default-features = false } num_cpus = "1" state = "0.2.1" @@ -35,6 +34,12 @@ pear_codegen = "0.0.8" rustls = { version = "0.5.8", optional = true } cookie = { version = "0.7.4", features = ["percent-encode", "secure"] } +[dependencies.hyper] +git = "https://github.com/SergioBenitez/hyper" +branch = "0.10.x" +version = "0.10.4" +default-features = false + [dependencies.hyper-rustls] git = "https://github.com/SergioBenitez/hyper-rustls" default-features = false diff --git a/lib/src/error.rs b/lib/src/error.rs index 65008a36..4cecd2be 100644 --- a/lib/src/error.rs +++ b/lib/src/error.rs @@ -130,6 +130,13 @@ impl From for LaunchError { } } +impl From for LaunchError { + #[inline] + fn from(error: io::Error) -> LaunchError { + LaunchError::new(LaunchErrorKind::Io(error)) + } +} + impl fmt::Display for LaunchErrorKind { #[inline] fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { diff --git a/lib/src/rocket.rs b/lib/src/rocket.rs index 0131db00..b298578b 100644 --- a/lib/src/rocket.rs +++ b/lib/src/rocket.rs @@ -601,15 +601,20 @@ impl Rocket { let full_addr = format!("{}:{}", self.config.address, self.config.port); serve!(self, &full_addr, |server, proto| { - let server = match server { + let mut server = match server { Ok(server) => server, Err(e) => return LaunchError::from(e) }; + let (addr, port) = match server.local_addr() { + Ok(server_addr) => (&self.config.address, server_addr.port()), + Err(e) => return LaunchError::from(e) + }; + launch_info!("🚀 {} {}{}", White.paint("Rocket has launched from"), White.bold().paint(proto), - White.bold().paint(&full_addr)); + White.bold().paint(&format!("{}:{}", addr, port))); let threads = self.config.workers as usize; if let Err(e) = server.handle_threads(self, threads) {