mirror of
https://github.com/actix/actix-web.git
synced 2024-12-25 17:40:36 +00:00
add host and port for test server
This commit is contained in:
parent
f8e170fdaf
commit
6fe741025f
1 changed files with 20 additions and 1 deletions
|
@ -40,6 +40,8 @@ pub struct TestServer;
|
|||
/// Test server runstime
|
||||
pub struct TestServerRuntime {
|
||||
addr: net::SocketAddr,
|
||||
host: String,
|
||||
port: u16,
|
||||
rt: Runtime,
|
||||
}
|
||||
|
||||
|
@ -68,8 +70,15 @@ impl TestServer {
|
|||
System::set_current(system);
|
||||
|
||||
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
|
||||
|
@ -100,6 +109,16 @@ impl TestServerRuntime {
|
|||
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
|
||||
pub fn addr(&self) -> net::SocketAddr {
|
||||
self.addr
|
||||
|
|
Loading…
Reference in a new issue