aboutsummaryrefslogtreecommitdiff
path: root/src/routes
diff options
context:
space:
mode:
Diffstat (limited to 'src/routes')
-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