Simplify resolving of location addresses
This commit is contained in:
parent
0d30090e5b
commit
d909462cc4
1 changed files with 2 additions and 9 deletions
11
src/api.rs
11
src/api.rs
|
|
@ -33,15 +33,8 @@ pub(crate) struct Location {
|
|||
|
||||
impl Location {
|
||||
pub(crate) fn get_endpoint(&self) -> anyhow::Result<SocketAddr> {
|
||||
let endpoint_addr_with_port: String;
|
||||
let endpoint_addr = if self.pool.contains(':') {
|
||||
&self.pool
|
||||
} else {
|
||||
endpoint_addr_with_port = format!("{}:51820", self.pool);
|
||||
&endpoint_addr_with_port
|
||||
};
|
||||
let mut endpoints = endpoint_addr.to_socket_addrs()?;
|
||||
endpoints
|
||||
(self.pool.as_str(), 51820)
|
||||
.to_socket_addrs()?
|
||||
.next()
|
||||
.ok_or_else(|| anyhow!("no valid endpoint address"))
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue