Skip to content

Commit

Permalink
Allow client to connect to own instance
Browse files Browse the repository at this point in the history
If "https://nominatim.openstreetmap.org/" is unavailable a
client can be constructed presently
  • Loading branch information
Bolognafingers committed Oct 13, 2023
1 parent fd375bc commit dd4d6b4
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,20 @@ impl Client {
}
}

pub fn with_url(ident: IdentificationMethod, url: Url) -> Self {
let timeout = Duration::from_secs(10);

Self {
ident,
base_url: url,
client: reqwest::ClientBuilder::new()
.timeout(timeout)
.build()
.unwrap(),
timeout,
}
}

/// Set the client's internal base url for all requests.
pub fn set_base_url<U: TryInto<Url>>(&mut self, url: U) -> Result<(), U::Error> {
self.base_url = url.try_into()?;
Expand Down

0 comments on commit dd4d6b4

Please sign in to comment.