mirror of
https://github.com/actix/actix-extras.git
synced 2024-12-01 02:44:37 +01:00
Added support for returning addresses plus scheme from the server
This commit is contained in:
parent
6e976153e7
commit
7bb7d85c1d
@ -211,6 +211,16 @@ where
|
|||||||
self.sockets.iter().map(|s| s.addr).collect()
|
self.sockets.iter().map(|s| s.addr).collect()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Get addresses of bound sockets and the scheme for it.
|
||||||
|
///
|
||||||
|
/// This is useful when the server is bound from different sources
|
||||||
|
/// with some sockets listening on http and some listening on https
|
||||||
|
/// and the user should be presented with an enumeration of which
|
||||||
|
/// socket requires which protocol.
|
||||||
|
pub fn addrs_with_scheme(&self) -> Vec<(net::SocketAddr, &str)> {
|
||||||
|
self.sockets.iter().map(|s| (s.addr, s.tp.scheme())).collect()
|
||||||
|
}
|
||||||
|
|
||||||
/// Use listener for accepting incoming connection requests
|
/// Use listener for accepting incoming connection requests
|
||||||
///
|
///
|
||||||
/// HttpServer does not change any configuration for TcpListener,
|
/// HttpServer does not change any configuration for TcpListener,
|
||||||
|
@ -239,4 +239,14 @@ impl StreamHandlerType {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub(crate) fn scheme(&self) -> &'static str {
|
||||||
|
match *self {
|
||||||
|
StreamHandlerType::Normal => "http",
|
||||||
|
#[cfg(feature = "tls")]
|
||||||
|
StreamHandlerType::Tls(ref acceptor) => "https",
|
||||||
|
#[cfg(feature = "alpn")]
|
||||||
|
StreamHandlerType::Alpn(ref acceptor) => "https",
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user