summaryrefslogtreecommitdiffstats
path: root/ipfs-api-backend-actix
diff options
context:
space:
mode:
Diffstat (limited to 'ipfs-api-backend-actix')
-rw-r--r--ipfs-api-backend-actix/Cargo.toml4
-rw-r--r--ipfs-api-backend-actix/src/backend.rs23
-rw-r--r--ipfs-api-backend-actix/src/error.rs13
3 files changed, 11 insertions, 29 deletions
diff --git a/ipfs-api-backend-actix/Cargo.toml b/ipfs-api-backend-actix/Cargo.toml
index 3a616a6..22e4ba9 100644
--- a/ipfs-api-backend-actix/Cargo.toml
+++ b/ipfs-api-backend-actix/Cargo.toml
@@ -20,7 +20,5 @@ bytes = "1.0"
futures = "0.3"
http = "0.2"
ipfs-api-prelude = { version = "0.1.0", path = "../ipfs-api-prelude" }
-serde = { version = "1.0", features = ["derive"] }
-serde_json = "1.0"
-serde_urlencoded = "0.7"
+serde = "1.0"
thiserror = "1.0"
diff --git a/ipfs-api-backend-actix/src/backend.rs b/ipfs-api-backend-actix/src/backend.rs
index 6aa8f50..f61d70d 100644
--- a/ipfs-api-backend-actix/src/backend.rs
+++ b/ipfs-api-backend-actix/src/backend.rs
@@ -54,19 +54,16 @@ impl Backend for ActixBackend {
where
Req: ApiRequest,
{
- req.absolute_url(&self.base).and_then(|url| {
- let req = if let Some(form) = form {
- self.client
- .post(url)
- .timeout(ACTIX_REQUEST_TIMEOUT)
- .content_type(form.content_type())
- .send_body(multipart::client::multipart::Body::from(form))
- } else {
- self.client.post(url).timeout(ACTIX_REQUEST_TIMEOUT).send()
- };
-
- Ok(req)
- })
+ let url = req.absolute_url(&self.base)?;
+ let req = self.client.request(Req::METHOD, url);
+ let req = if let Some(form) = form {
+ req.content_type(form.content_type())
+ .send_body(multipart::Body::from(form))
+ } else {
+ req.timeout(ACTIX_REQUEST_TIMEOUT).send()
+ };
+
+ Ok(req)
}
fn get_header<'a>(res: &'a Self::HttpResponse, key: HeaderName) -> Option<&'a HeaderValue> {
diff --git a/ipfs-api-backend-actix/src/error.rs b/ipfs-api-backend-actix/src/error.rs
index 4cd9a25..aad2b05 100644
--- a/ipfs-api-backend-actix/src/error.rs
+++ b/ipfs-api-backend-actix/src/error.rs
@@ -6,7 +6,6 @@
// copied, modified, or distributed except according to those terms.
//
-use std::string::FromUtf8Error;
use thiserror::Error;
#[derive(Debug, Error)]
@@ -23,18 +22,6 @@ pub enum Error {
#[error("http error `{0}`")]
Http(#[from] http::Error),
- #[error("json parse error `{0}`")]
- Parse(#[from] serde_json::Error),
-
- #[error("utf8 decoding error `{0}`")]
- ParseUtf8(#[from] FromUtf8Error),
-
- #[error("uri error `{0}`")]
- Url(#[from] http::uri::InvalidUri),
-
- #[error("url encoding error `{0}`")]
- EncodeUrl(#[from] serde_urlencoded::ser::Error),
-
#[error("ipfs client error `{0}`")]
IpfsClientError(#[from] ipfs_api_prelude::Error),
}