Browse Source

use helper functions for get request

Steven Jacobs 2 years ago
parent
commit
6f596cc68a
1 changed files with 2 additions and 11 deletions
  1. 2 11
      src/linode.rs

+ 2 - 11
src/linode.rs

@@ -1,8 +1,5 @@
 pub mod instances {
     use helper;
-    use hyper::header::Headers;
-    use reqwest;
-    use url::Url;
 
     #[derive(Debug, Deserialize)]
     pub struct Instance {
@@ -31,14 +28,8 @@ pub mod instances {
     }
 
     pub fn get(id: &u32) -> Instance {
-        let client = reqwest::Client::new().expect("client failed to construct");
-        let headers: Headers = helper::gen_headers();
-        let url: Url = helper::gen_url(format!("linode/instances/{}", id).as_str());
-
-        let mut res = client.get(url)
-            .headers(headers)
-            .send()
-            .unwrap();
+        let path = format!("linode/instances/{}", id);
+        let mut res = helper::gen_request("get", path.as_str());
 
         res.json().expect("Can't parse API data")
     }