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

Allow using custom client #114

Merged
merged 4 commits into from
Aug 30, 2024
Merged
Changes from 1 commit
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
11 changes: 11 additions & 0 deletions src/v3.rs
Original file line number Diff line number Diff line change
Expand Up @@ -217,6 +217,17 @@ impl Sender {
self.host = host.into();
}

/// Sets client to use for the API. This is useful if you want to customize the client.
pub fn set_client(&mut self, client: Client) {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe it would be better to allow new to accept an Option<Client> and just unwrap it or use a default one.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@gsquire

Is this what you meant? b5ea713

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Exactly. We'll need a new_blocking function as well so users can configure that client. Otherwise this LGTM.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added! @gsquire

62358ce

self.client = client;
}

/// Sets blocking client to use for the API. This is useful if you want to customize the client.
#[cfg(feature = "blocking")]
pub fn set_blocking_client(&mut self, blocking_client: reqwest::blocking::Client) {
self.blocking_client = blocking_client;
}

fn get_headers(&self) -> Result<HeaderMap, InvalidHeaderValue> {
let mut headers = HeaderMap::with_capacity(3);
headers.insert(
Expand Down
Loading