mirror of https://github.com/MedzikUser/imgurs
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
|
@ -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 New Issue