mirror of
https://github.com/MedzikUser/imgurs
synced 2024-08-15 00:03:19 +00:00
Add with_http_client
method to ImgurClient
This will allow customization of the http client or just providing an already existing http client. In my use case I already have a client I'd like to reuse.
This commit is contained in:
parent
25190ba5c1
commit
89a7969353
1 changed files with 16 additions and 0 deletions
|
@ -24,6 +24,22 @@ impl ImgurClient {
|
||||||
let client = reqwest::Client::new();
|
let client = reqwest::Client::new();
|
||||||
ImgurClient { client_id, client }
|
ImgurClient { client_id, client }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Create a new Imgur Client with the provided `reqwest::Client`
|
||||||
|
///
|
||||||
|
/// This allows for customization of the http client settings like timeout or the user agent.
|
||||||
|
/// ```
|
||||||
|
/// use imgurs::ImgurClient;
|
||||||
|
/// use reqwest::Client;
|
||||||
|
///
|
||||||
|
/// let http_client = Client::builder().build();
|
||||||
|
///
|
||||||
|
/// let client = ImgurClient::with_http_client("3e3ce0d7ac14d56", http_client);
|
||||||
|
/// ```
|
||||||
|
pub fn new(client_id: &str, http_client: reqwest::Client) -> Self {
|
||||||
|
let client_id = client_id.to_string();
|
||||||
|
ImgurClient { client_id, client: http_client }
|
||||||
|
}
|
||||||
|
|
||||||
/// Upload image to Imgur
|
/// Upload image to Imgur
|
||||||
/// ```
|
/// ```
|
||||||
|
|
Loading…
Reference in a new issue