diff options
Diffstat (limited to 'src/requests/device.rs')
-rw-r--r-- | src/requests/device.rs | 23 |
1 files changed, 10 insertions, 13 deletions
diff --git a/src/requests/device.rs b/src/requests/device.rs index a612978..7583406 100644 --- a/src/requests/device.rs +++ b/src/requests/device.rs | |||
@@ -1,4 +1,4 @@ | |||
1 | use crate::{config::Config, default_headers, error::Error, format_url, Protocols}; | 1 | use crate::{check_success, config::Config, default_headers, error::Error, format_url, Protocols}; |
2 | 2 | ||
3 | pub async fn put( | 3 | pub async fn put( |
4 | config: &Config, | 4 | config: &Config, |
@@ -16,11 +16,10 @@ pub async fn put( | |||
16 | r#"{{"id": "{id}", "mac": "{mac}", "broadcast_addr": "{broadcast_addr}", "ip": "{ip}"}}"#, | 16 | r#"{{"id": "{id}", "mac": "{mac}", "broadcast_addr": "{broadcast_addr}", "ip": "{ip}"}}"#, |
17 | )) | 17 | )) |
18 | .send() | 18 | .send() |
19 | .await? | 19 | .await?; |
20 | .text() | ||
21 | .await; | ||
22 | 20 | ||
23 | println!("{res:?}"); | 21 | let body = check_success(res).await?; |
22 | println!("{body}"); | ||
24 | Ok(()) | 23 | Ok(()) |
25 | } | 24 | } |
26 | 25 | ||
@@ -30,11 +29,10 @@ pub async fn get(config: &Config, id: String) -> Result<(), Error> { | |||
30 | .headers(default_headers(config)?) | 29 | .headers(default_headers(config)?) |
31 | .body(format!(r#"{{"id": "{id}"}}"#)) | 30 | .body(format!(r#"{{"id": "{id}"}}"#)) |
32 | .send() | 31 | .send() |
33 | .await? | 32 | .await?; |
34 | .text() | ||
35 | .await; | ||
36 | 33 | ||
37 | println!("{res:?}"); | 34 | let body = check_success(res).await?; |
35 | println!("{body}"); | ||
38 | Ok(()) | 36 | Ok(()) |
39 | } | 37 | } |
40 | 38 | ||
@@ -52,10 +50,9 @@ pub async fn post( | |||
52 | r#"{{"id": "{id}", "mac": "{mac}", "broadcast_addr": "{broadcast_addr}", "ip": "{ip}"}}"#, | 50 | r#"{{"id": "{id}", "mac": "{mac}", "broadcast_addr": "{broadcast_addr}", "ip": "{ip}"}}"#, |
53 | )) | 51 | )) |
54 | .send() | 52 | .send() |
55 | .await? | 53 | .await?; |
56 | .text() | ||
57 | .await; | ||
58 | 54 | ||
59 | println!("{res:?}"); | 55 | let body = check_success(res).await?; |
56 | println!("{body}"); | ||
60 | Ok(()) | 57 | Ok(()) |
61 | } | 58 | } |