Skip to content

Commit

Permalink
feat: add ApiClient::with_client
Browse files Browse the repository at this point in the history
  • Loading branch information
gadomski committed Apr 6, 2024
1 parent 5c80874 commit df99ee3
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 1 deletion.
4 changes: 4 additions & 0 deletions stac-async/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down
18 changes: 17 additions & 1 deletion stac-async/src/api_client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,24 @@ impl ApiClient {
/// ```
pub fn new(url: &str) -> Result<ApiClient> {
// 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<ApiClient> {
Ok(ApiClient {
client: Client::new(),
client,
channel_buffer: DEFAULT_CHANNEL_BUFFER,
url_builder: UrlBuilder::new(url)?,
})
Expand Down

0 comments on commit df99ee3

Please sign in to comment.