aboutsummaryrefslogtreecommitdiff
path: root/src/internal/macros.rs
diff options
context:
space:
mode:
authorZeyla Hellyer <[email protected]>2017-06-07 15:01:47 -0700
committerZeyla Hellyer <[email protected]>2017-06-07 15:01:47 -0700
commit8f8a05996c5b47ec9401aabb517d96ed2af5c36b (patch)
treeab48c3b558c396f4f6d12c98a466074f97f17acf /src/internal/macros.rs
parentWs read/write timeout after 90s (diff)
downloadserenity-8f8a05996c5b47ec9401aabb517d96ed2af5c36b.tar.xz
serenity-8f8a05996c5b47ec9401aabb517d96ed2af5c36b.zip
Upgrade rust-websocket, rust-openssl, and hyper
Upgrade `rust-websocket` to v0.20, maintaining use of its sync client. This indirectly switches from `rust-openssl` v0.7 - which required openssl-1.0 on all platforms - to `native-tls`, which allows for use of schannel on Windows, Secure Transport on OSX, and openssl-1.1 on other platforms. Additionally, since hyper is no longer even a dependency of rust-websocket, we can safely and easily upgrade to `hyper` v0.10 and `multipart` v0.12. This commit is fairly experimental as it has not been tested on a long-running bot.
Diffstat (limited to 'src/internal/macros.rs')
-rw-r--r--src/internal/macros.rs24
1 files changed, 20 insertions, 4 deletions
diff --git a/src/internal/macros.rs b/src/internal/macros.rs
index 1e09b2e..c2475d1 100644
--- a/src/internal/macros.rs
+++ b/src/internal/macros.rs
@@ -2,29 +2,45 @@
macro_rules! request {
($route:expr, $method:ident($body:expr), $url:expr, $($rest:tt)*) => {{
- let client = HyperClient::new();
+ let client = request_client!();
+
request($route, || client
.$method(&format!(api!($url), $($rest)*))
.body(&$body))?
}};
($route:expr, $method:ident($body:expr), $url:expr) => {{
- let client = HyperClient::new();
+ let client = request_client!();
+
request($route, || client
.$method(api!($url))
.body(&$body))?
}};
($route:expr, $method:ident, $url:expr, $($rest:tt)*) => {{
- let client = HyperClient::new();
+ let client = request_client!();
+
request($route, || client
.$method(&format!(api!($url), $($rest)*)))?
}};
($route:expr, $method:ident, $url:expr) => {{
- let client = HyperClient::new();
+ let client = request_client!();
+
request($route, || client
.$method(api!($url)))?
}};
}
+macro_rules! request_client {
+ () => {{
+ use hyper::net::HttpsConnector;
+ use hyper_native_tls::NativeTlsClient;
+
+ let tc = NativeTlsClient::new()?;
+ let connector = HttpsConnector::new(tc);
+
+ HyperClient::with_connector(connector)
+ }}
+}
+
macro_rules! cdn {
($e:expr) => {
concat!("https://cdn.discordapp.com", $e)