From 352dd535e0386d899e816ac5f597e583d1ade768 Mon Sep 17 00:00:00 2001 From: FxQnLr Date: Wed, 10 Apr 2024 12:06:45 +0200 Subject: Closes #8. 0.4.0 seems to work --- src/requests/device.rs | 7 +++---- src/requests/start.rs | 8 ++++---- 2 files changed, 7 insertions(+), 8 deletions(-) (limited to 'src/requests') diff --git a/src/requests/device.rs b/src/requests/device.rs index 7583406..2606579 100644 --- a/src/requests/device.rs +++ b/src/requests/device.rs @@ -7,7 +7,7 @@ pub async fn put( broadcast_addr: String, ip: String, ) -> Result<(), Error> { - let url = format_url(config, "device", &Protocols::Http); + let url = format_url(config, "device", &Protocols::Http, None); println!("{url}"); let res = reqwest::Client::new() .put(url) @@ -25,9 +25,8 @@ pub async fn put( pub async fn get(config: &Config, id: String) -> Result<(), Error> { let res = reqwest::Client::new() - .get(format_url(config, "device", &Protocols::Http)) + .get(format_url(config, "device", &Protocols::Http, Some(&id))) .headers(default_headers(config)?) - .body(format!(r#"{{"id": "{id}"}}"#)) .send() .await?; @@ -44,7 +43,7 @@ pub async fn post( ip: String, ) -> Result<(), Error> { let res = reqwest::Client::new() - .post(format_url(config, "device", &Protocols::Http)) + .post(format_url(config, "device", &Protocols::Http, None)) .headers(default_headers(config)?) .body(format!( r#"{{"id": "{id}", "mac": "{mac}", "broadcast_addr": "{broadcast_addr}", "ip": "{ip}"}}"#, diff --git a/src/requests/start.rs b/src/requests/start.rs index 3afbe3a..1ec3ce8 100644 --- a/src/requests/start.rs +++ b/src/requests/start.rs @@ -17,12 +17,12 @@ pub async fn start(config: &Config, id: String, ping: bool) -> Result<(), Error> let send_start = MultiProgress::new(); let overview = add_pb(&send_start, OVERVIEW_STYLE, format!(") start {id}")); - let url = format_url(config, "start", &Protocols::Http); + let url = format_url(config, "start", &Protocols::Http, Some(&id)); let connect = add_pb(&send_start, DEFAULT_STYLE, format!("connect to {url}")); let res = reqwest::Client::new() .post(url) .headers(default_headers(config)?) - .body(format!(r#"{{"id": "{id}", "ping": {ping}}}"#)) + .body(format!(r#"{{"ping": {ping}}}"#)) .send() .await?; finish_pb(&connect, "connected, got response".to_string(), DONE_STYLE); @@ -71,8 +71,8 @@ async fn status_socket( let ws_pb = add_pb(pb, DEFAULT_STYLE, "connect to websocket".to_string()); let request = Request::builder() - .uri(format_url(config, "status", &Protocols::Websocket)) - .header("Authorization", &config.apikey) + .uri(format_url(config, "status", &Protocols::Websocket, None)) + .header("Authorization", &config.auth.secret) .header("sec-websocket-key", "") .header("host", &config.server) .header("upgrade", "websocket") -- cgit v1.2.3