From b4f59c226c6916a3e45f1a52dc6a9b15c800297a Mon Sep 17 00:00:00 2001 From: fx Date: Wed, 18 Oct 2023 15:11:44 +0200 Subject: basic cli, only start and get device --- src/requests/get.rs | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 src/requests/get.rs (limited to 'src/requests/get.rs') diff --git a/src/requests/get.rs b/src/requests/get.rs new file mode 100644 index 0000000..225562d --- /dev/null +++ b/src/requests/get.rs @@ -0,0 +1,21 @@ +use crate::{error::CliError, config::SETTINGS, default_headers}; + +pub fn get(id: String) -> Result<(), CliError> { + let res = reqwest::blocking::Client::new() + .get( + format!( + "{}/start", + SETTINGS.get_string("server").map_err(CliError::Config)? + ) + ) + .headers(default_headers()?) + .body( + format!(r#"{{"id": "{}"}}"#, id) + ) + .send() + .map_err(CliError::Reqwest)? + .text(); + + println!("{:?}", res); + Ok(()) +} -- cgit v1.2.3