aboutsummaryrefslogtreecommitdiff
path: root/src/routes/start.rs
diff options
context:
space:
mode:
authorFxQnLr <[email protected]>2023-11-02 20:57:47 +0100
committerFxQnLr <[email protected]>2023-11-02 20:57:47 +0100
commit94104b621e2eec44dd90eb22fae2db2ce4938b87 (patch)
treec357bcaca0681caf9a6742c857bb494dc4315900 /src/routes/start.rs
parent5b7302cf9be4e0badd691203e160ca110613e34c (diff)
downloadwebol-94104b621e2eec44dd90eb22fae2db2ce4938b87.tar
webol-94104b621e2eec44dd90eb22fae2db2ce4938b87.tar.gz
webol-94104b621e2eec44dd90eb22fae2db2ce4938b87.zip
update dependencies
Diffstat (limited to 'src/routes/start.rs')
-rw-r--r--src/routes/start.rs5
1 files changed, 2 insertions, 3 deletions
diff --git a/src/routes/start.rs b/src/routes/start.rs
index 9cd358b..271f924 100644
--- a/src/routes/start.rs
+++ b/src/routes/start.rs
@@ -4,7 +4,7 @@ use serde::{Deserialize, Serialize};
4use std::sync::Arc; 4use std::sync::Arc;
5use axum::extract::State; 5use axum::extract::State;
6use serde_json::{json, Value}; 6use serde_json::{json, Value};
7use tracing::{debug, info, warn}; 7use tracing::{debug, info};
8use uuid::Uuid; 8use uuid::Uuid;
9use crate::auth::auth; 9use crate::auth::auth;
10use crate::config::SETTINGS; 10use crate::config::SETTINGS;
@@ -16,7 +16,6 @@ use crate::services::ping::PingValue;
16#[axum_macros::debug_handler] 16#[axum_macros::debug_handler]
17pub async fn start(State(state): State<Arc<crate::AppState>>, headers: HeaderMap, Json(payload): Json<StartPayload>) -> Result<Json<Value>, WebolError> { 17pub async fn start(State(state): State<Arc<crate::AppState>>, headers: HeaderMap, Json(payload): Json<StartPayload>) -> Result<Json<Value>, WebolError> {
18 info!("POST request"); 18 info!("POST request");
19 warn!("{:?}", state.ping_map);
20 let secret = headers.get("authorization"); 19 let secret = headers.get("authorization");
21 let authorized = auth(secret).map_err(WebolError::Auth)?; 20 let authorized = auth(secret).map_err(WebolError::Auth)?;
22 if authorized { 21 if authorized {
@@ -46,7 +45,7 @@ pub async fn start(State(state): State<Arc<crate::AppState>>, headers: HeaderMap
46 let uuid_gen = Uuid::new_v4().to_string(); 45 let uuid_gen = Uuid::new_v4().to_string();
47 let uuid_genc = uuid_gen.clone(); 46 let uuid_genc = uuid_gen.clone();
48 tokio::spawn(async move { 47 tokio::spawn(async move {
49 debug!("Init ping service"); 48 debug!("init ping service");
50 state.ping_map.insert(uuid_gen.clone(), PingValue { ip: device.ip.clone(), online: false }); 49 state.ping_map.insert(uuid_gen.clone(), PingValue { ip: device.ip.clone(), online: false });
51 50
52 crate::services::ping::spawn(state.ping_send.clone(), device.ip, uuid_gen.clone(), &state.ping_map).await 51 crate::services::ping::spawn(state.ping_send.clone(), device.ip, uuid_gen.clone(), &state.ping_map).await