Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add ApiClient::with_client #227

Merged
merged 1 commit into from
Apr 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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