diff --git a/stac-async/CHANGELOG.md b/stac-async/CHANGELOG.md index 3bcc1d01..87ea1668 100644 --- a/stac-async/CHANGELOG.md +++ b/stac-async/CHANGELOG.md @@ -6,6 +6,10 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), ## [Unreleased] +### Added + +- `ApiClient::with_client` ([#227](https://github.com/stac-utils/stac-rs/pull/227)) + ### Removed - Downloading (use [stac-asset](https://github.com/stac-utils/stac-asset) instead) ([#194](https://github.com/stac-utils/stac-rs/pull/194)) diff --git a/stac-async/src/api_client.rs b/stac-async/src/api_client.rs index f951a468..2e628ee4 100644 --- a/stac-async/src/api_client.rs +++ b/stac-async/src/api_client.rs @@ -28,8 +28,24 @@ impl ApiClient { /// ``` pub fn new(url: &str) -> Result { // TODO support HATEOS (aka look up the urls from the root catalog) + ApiClient::with_client(Client::new(), url) + } + + /// Creates a new API client with the given [Client]. + /// + /// Useful if you want to customize the behavior of the underlying `Client`, + /// as documented in [Client::new]. + /// + /// # Examples + /// + /// ``` + /// use stac_async::{Client, ApiClient}; + /// let client = Client::new(); + /// let api_client = ApiClient::with_client(client, "https://earth-search.aws.element84.com/v1/").unwrap(); + /// ``` + pub fn with_client(client: Client, url: &str) -> Result { Ok(ApiClient { - client: Client::new(), + client, channel_buffer: DEFAULT_CHANNEL_BUFFER, url_builder: UrlBuilder::new(url)?, })