mirror of
https://github.com/Start9Labs/rpc-toolkit.git
synced 2026-03-26 02:11:56 +00:00
context path
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user