v6.1 fixed routes not deserialising correctly.

master
Aaron Power 8 years ago
parent 39e539646b
commit 5332b47ede
  1. 2
      Cargo.toml
  2. 20
      src/lib.rs

@ -1,6 +1,6 @@
[package]
name = "mammut"
version = "0.6.0"
version = "0.6.1"
description = "A wrapper around the Mastodon API."
authors = ["Aaron Power <theaaronepower@gmail.com>"]
license = "MIT/Apache-2.0"

@ -69,11 +69,20 @@ macro_rules! methods {
fn $method<T: serde::Deserialize>(&self, url: String)
-> Result<T>
{
use std::io::Read;
let mut response = self.client.$method(&url)
.headers(self.headers.clone())
.send()?;
response.json()?
let mut vec = Vec::new();
response.read_to_end(&mut vec)?;
if let Ok(t) = json::from_slice(&vec) {
Ok(t)
} else {
Err(Error::Api(json::from_slice(&vec)?))
}
}
)+
};
@ -106,7 +115,11 @@ macro_rules! route {
response.read_to_end(&mut vec)?;
json::from_slice(&vec)?
if let Ok(t) = json::from_slice(&vec) {
Ok(t)
} else {
Err(Error::Api(json::from_slice(&vec)?))
}
}
route!{$($rest)*}
};
@ -279,8 +292,7 @@ impl Mastodon {
let mut response = self.client.post(&self.route("/api/v1/statuses"))
.headers(self.headers.clone())
.json(&status)
.send().expect("STAUS BUILDER IS BAD");
.send()?;
let mut vec = Vec::new();
response.read_to_end(&mut vec)?;

Loading…
Cancel
Save