1
0
mirror of https://github.com/fafhrd91/actix-net synced 2025-09-01 02:36:59 +02:00

merge -connect and -tls and upgrade to rt v2 (#238)

This commit is contained in:
Rob Ede
2020-12-29 00:38:41 +00:00
committed by GitHub
parent 3c6de3a81b
commit 5759c9e144
24 changed files with 212 additions and 507 deletions

View File

@@ -0,0 +1,37 @@
use http::Uri;
use super::Address;
impl Address for Uri {
fn host(&self) -> &str {
self.host().unwrap_or("")
}
fn port(&self) -> Option<u16> {
if let Some(port) = self.port_u16() {
Some(port)
} else {
port(self.scheme_str())
}
}
}
// TODO: load data from file
fn port(scheme: Option<&str>) -> Option<u16> {
if let Some(scheme) = scheme {
match scheme {
"http" => Some(80),
"https" => Some(443),
"ws" => Some(80),
"wss" => Some(443),
"amqp" => Some(5672),
"amqps" => Some(5671),
"sb" => Some(5671),
"mqtt" => Some(1883),
"mqtts" => Some(8883),
_ => None,
}
} else {
None
}
}