refactor(web/converse): Use crimp instead of reqwest
This simpler, curl-based HTTP client (which I wrote years ago) is a first step towards cleaning up the dependency mess of converse. Dependency stats: +4, -28 Change-Id: I4f5f3c9307895d261bfb0a6bcf2337b747f9a4c0 Reviewed-on: https://cl.tvl.fyi/c/depot/+/2859 Tested-by: BuildkiteCI Reviewed-by: tazjin <mail@tazj.in>
This commit is contained in:
parent
8fc4e083c9
commit
3b0b21f8d1
5 changed files with 114 additions and 378 deletions
|
|
@ -31,7 +31,6 @@ use actix_web;
|
|||
use askama;
|
||||
use diesel;
|
||||
use r2d2;
|
||||
use reqwest;
|
||||
use tokio_timer;
|
||||
|
||||
pub type Result<T> = result::Result<T, ConverseError>;
|
||||
|
|
@ -62,6 +61,9 @@ pub enum ConverseError {
|
|||
#[fail(display = "thread {} is closed and can not be responded to", id)]
|
||||
ThreadClosed { id: i32 },
|
||||
|
||||
#[fail(display = "JSON serialisation failed: {}", error)]
|
||||
Serialisation { error: serde_json::Error },
|
||||
|
||||
// This variant is used as a catch-all for wrapping
|
||||
// actix-web-compatible response errors, such as the errors it
|
||||
// throws itself.
|
||||
|
|
@ -103,10 +105,16 @@ impl From<actix_web::Error> for ConverseError {
|
|||
}
|
||||
}
|
||||
|
||||
impl From<reqwest::Error> for ConverseError {
|
||||
fn from(error: reqwest::Error) -> ConverseError {
|
||||
impl From<serde_json::Error> for ConverseError {
|
||||
fn from(error: serde_json::Error) -> ConverseError {
|
||||
ConverseError::Serialisation { error }
|
||||
}
|
||||
}
|
||||
|
||||
impl From<curl::Error> for ConverseError {
|
||||
fn from(error: curl::Error) -> ConverseError {
|
||||
ConverseError::InternalError {
|
||||
reason: format!("Failed to make HTTP request: {}", error),
|
||||
reason: format!("error during HTTP request: {}", error),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue