mirror of
https://github.com/fafhrd91/actix-net
synced 2024-11-27 18:02:58 +01:00
add host and port for test server
This commit is contained in:
parent
f8e170fdaf
commit
6fe741025f
@ -40,6 +40,8 @@ pub struct TestServer;
|
|||||||
/// Test server runstime
|
/// Test server runstime
|
||||||
pub struct TestServerRuntime {
|
pub struct TestServerRuntime {
|
||||||
addr: net::SocketAddr,
|
addr: net::SocketAddr,
|
||||||
|
host: String,
|
||||||
|
port: u16,
|
||||||
rt: Runtime,
|
rt: Runtime,
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -68,8 +70,15 @@ impl TestServer {
|
|||||||
System::set_current(system);
|
System::set_current(system);
|
||||||
|
|
||||||
let rt = Runtime::new().unwrap();
|
let rt = Runtime::new().unwrap();
|
||||||
|
let host = format!("{}", addr.ip());
|
||||||
|
let port = addr.port();
|
||||||
|
|
||||||
TestServerRuntime { addr, rt }
|
TestServerRuntime {
|
||||||
|
addr,
|
||||||
|
rt,
|
||||||
|
host,
|
||||||
|
port,
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Get firat available unused local address
|
/// Get firat available unused local address
|
||||||
@ -100,6 +109,16 @@ impl TestServerRuntime {
|
|||||||
self.rt.spawn(fut);
|
self.rt.spawn(fut);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Test server host
|
||||||
|
pub fn host(&self) -> &str {
|
||||||
|
&self.host
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Test server port
|
||||||
|
pub fn port(&self) -> u16 {
|
||||||
|
self.port
|
||||||
|
}
|
||||||
|
|
||||||
/// Get test server address
|
/// Get test server address
|
||||||
pub fn addr(&self) -> net::SocketAddr {
|
pub fn addr(&self) -> net::SocketAddr {
|
||||||
self.addr
|
self.addr
|
||||||
|
Loading…
Reference in New Issue
Block a user