context path

This commit is contained in:
Aiden McClelland
2021-07-29 14:47:17 -06:00
parent 38c4ba0dc2
commit 75a8053a3c

View File

@@ -7,19 +7,25 @@ lazy_static! {
}
pub trait Context {
fn protocol(&self) -> &str {
"http"
}
fn host(&self) -> Host<&str> {
Host::Ipv4([127, 0, 0, 1].into())
}
fn port(&self) -> u16 {
8080
}
fn protocol(&self) -> &str {
"http"
fn path(&self) -> &str {
"/"
}
fn url(&self) -> Url {
format!("{}://{}:{}", self.protocol(), self.host(), self.port())
.parse()
.unwrap()
let mut url: Url = "http://localhost".parse().unwrap();
url.set_scheme(self.protocol()).expect("protocol");
url.set_host(Some(&self.host().to_string())).expect("host");
url.set_port(Some(self.port())).expect("port");
url.set_path(self.path());
url
}
fn client(&self) -> &Client {
&*DEFAULT_CLIENT