diff --git a/src/blocking.rs b/src/blocking.rs index dabb45ca..6e7a8560 100644 --- a/src/blocking.rs +++ b/src/blocking.rs @@ -12,10 +12,15 @@ pub struct Slack { impl Slack { /// Construct a new instance of slack for a specific incoming url endpoint. pub fn new(hook: T) -> Result { - Ok(Slack { - hook: hook.into_url()?, - client: Client::new(), - }) + Self::new_with_client(hook, Client::new()) + } + + /// The same as [`Slack::new()`], but with a custom [`reqwest::Client`] + /// + /// This allows for configuring custom proxies, DNS resolvers, etc. + pub fn new_with_client(hook: T, client: Client) -> Result { + let hook = hook.into_url()?; + Ok(Self { hook, client }) } /// Send payload to slack service diff --git a/src/slack.rs b/src/slack.rs index d9c4c5e0..50d1f3bd 100644 --- a/src/slack.rs +++ b/src/slack.rs @@ -14,10 +14,15 @@ pub struct Slack { impl Slack { /// Construct a new instance of slack for a specific incoming url endpoint. pub fn new(hook: T) -> Result { - Ok(Slack { - hook: hook.into_url()?, - client: Client::new(), - }) + Self::new_with_client(hook, Client::new()) + } + + /// The same as [`Slack::new()`], but with a custom [`reqwest::Client`] + /// + /// This allows for configuring custom proxies, DNS resolvers, etc. + pub fn new_with_client(hook: T, client: Client) -> Result { + let hook = hook.into_url()?; + Ok(Self { hook, client }) } /// Send payload to slack service