mirror of
https://github.com/Start9Labs/rpc-toolkit.git
synced 2026-04-04 14:39:43 +00:00
context path
This commit is contained in:
@@ -7,19 +7,25 @@ lazy_static! {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub trait Context {
|
pub trait Context {
|
||||||
|
fn protocol(&self) -> &str {
|
||||||
|
"http"
|
||||||
|
}
|
||||||
fn host(&self) -> Host<&str> {
|
fn host(&self) -> Host<&str> {
|
||||||
Host::Ipv4([127, 0, 0, 1].into())
|
Host::Ipv4([127, 0, 0, 1].into())
|
||||||
}
|
}
|
||||||
fn port(&self) -> u16 {
|
fn port(&self) -> u16 {
|
||||||
8080
|
8080
|
||||||
}
|
}
|
||||||
fn protocol(&self) -> &str {
|
fn path(&self) -> &str {
|
||||||
"http"
|
"/"
|
||||||
}
|
}
|
||||||
fn url(&self) -> Url {
|
fn url(&self) -> Url {
|
||||||
format!("{}://{}:{}", self.protocol(), self.host(), self.port())
|
let mut url: Url = "http://localhost".parse().unwrap();
|
||||||
.parse()
|
url.set_scheme(self.protocol()).expect("protocol");
|
||||||
.unwrap()
|
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 {
|
fn client(&self) -> &Client {
|
||||||
&*DEFAULT_CLIENT
|
&*DEFAULT_CLIENT
|
||||||
|
|||||||
Reference in New Issue
Block a user