Skip to content

Commit f4c561d

Browse files
authored
Merge pull request #21 from tnull/2023-12-add-from-client
Add a `VssClient::from_client` constructor
2 parents 23d6f0a + e07d05a commit f4c561d

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

src/client.rs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,19 @@ impl VssClient {
2020
/// Constructs a [`VssClient`] using `base_url` as the VSS server endpoint.
2121
pub fn new(base_url: &str) -> Self {
2222
let client = Client::new();
23+
Self::from_client(base_url, client)
24+
}
25+
26+
/// Constructs a [`VssClient`] from a given [`reqwest::Client`], using `base_url` as the VSS server endpoint.
27+
pub fn from_client(base_url: &str, client: Client) -> Self {
2328
Self { base_url: String::from(base_url), client }
2429
}
2530

31+
/// Returns the underlying base URL.
32+
pub fn base_url(&self) -> &str {
33+
&self.base_url
34+
}
35+
2636
/// Fetches a value against a given `key` in `request`.
2737
/// Makes a service call to the `GetObject` endpoint of the VSS server.
2838
/// For API contract/usage, refer to docs for [`GetObjectRequest`] and [`GetObjectResponse`].

0 commit comments

Comments
 (0)