Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /// Send a given request and deserialize the response
- pub fn send_and_deserialize(&self, header: OAuthAuthorizationHeader) -> Result<Root, Error> {
- let req = self.clone();
- // Send the request
- let mut response = req
- .client
- .hyper
- .request(req.method, &req.url)
- .header(Authorization(header.to_string()))
- .send()?;
- // Read our response and write to a buffer.
- // We can just `unwrap` here since we already error checked.
- let mut buf = String::new();
- response.read_to_string(&mut buf);
- // deserialize from JSON to a `Root` object
- serde_json::from_str(&buf)
- }
Add Comment
Please, Sign In to add comment