aboutsummaryrefslogtreecommitdiff
path: root/src/http/mod.rs
diff options
context:
space:
mode:
authorLakelezz <[email protected]>2018-11-19 23:27:34 +0100
committerGitHub <[email protected]>2018-11-19 23:27:34 +0100
commit1f71892c8714eff8b69908989f91acb32391acea (patch)
tree1d00a1a16d68f322bb55b155e3eda90f94d2ccbf /src/http/mod.rs
parentRemove everything marked `deprecated` since `v0.5.x` or older (#441) (diff)
downloadserenity-1f71892c8714eff8b69908989f91acb32391acea.tar.xz
serenity-1f71892c8714eff8b69908989f91acb32391acea.zip
Replace `hyper` with `reqwest` (#440)
Diffstat (limited to 'src/http/mod.rs')
-rw-r--r--src/http/mod.rs31
1 files changed, 12 insertions, 19 deletions
diff --git a/src/http/mod.rs b/src/http/mod.rs
index e7e2bea..8093843 100644
--- a/src/http/mod.rs
+++ b/src/http/mod.rs
@@ -30,16 +30,14 @@ pub mod routing;
mod error;
-pub use hyper::status::{StatusClass, StatusCode};
+pub use reqwest::StatusCode;
pub use self::error::Error as HttpError;
pub use self::raw::*;
-use hyper::{
- client::Client as HyperClient,
- method::Method,
- net::HttpsConnector,
+use reqwest::{
+ Client as ReqwestClient,
+ Method,
};
-use hyper_native_tls::NativeTlsClient;
use model::prelude::*;
use parking_lot::Mutex;
use self::{request::Request};
@@ -51,17 +49,12 @@ use std::{
};
lazy_static! {
- static ref CLIENT: HyperClient = {
- let tc = NativeTlsClient::new().expect("Unable to make http client");
- let connector = HttpsConnector::new(tc);
-
- HyperClient::with_connector(connector)
- };
+ static ref CLIENT: ReqwestClient = ReqwestClient::new();
}
/// An method used for ratelimiting special routes.
///
-/// This is needed because `hyper`'s `Method` enum does not derive Copy.
+/// This is needed because `reqwest`'s `Method` enum does not derive Copy.
#[derive(Clone, Copy, Debug, Eq, Hash, PartialEq)]
pub enum LightMethod {
/// Indicates that a route is for the `DELETE` method only.
@@ -77,13 +70,13 @@ pub enum LightMethod {
}
impl LightMethod {
- pub fn hyper_method(&self) -> Method {
+ pub fn reqwest_method(&self) -> Method {
match *self {
- LightMethod::Delete => Method::Delete,
- LightMethod::Get => Method::Get,
- LightMethod::Patch => Method::Patch,
- LightMethod::Post => Method::Post,
- LightMethod::Put => Method::Put,
+ LightMethod::Delete => Method::DELETE,
+ LightMethod::Get => Method::GET,
+ LightMethod::Patch => Method::PATCH,
+ LightMethod::Post => Method::POST,
+ LightMethod::Put => Method::PUT,
}
}
}