diff options
Diffstat (limited to 'src/routes/start.rs')
-rw-r--r-- | src/routes/start.rs | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/src/routes/start.rs b/src/routes/start.rs index 271f924..9cd358b 100644 --- a/src/routes/start.rs +++ b/src/routes/start.rs | |||
@@ -4,7 +4,7 @@ use serde::{Deserialize, Serialize}; | |||
4 | use std::sync::Arc; | 4 | use std::sync::Arc; |
5 | use axum::extract::State; | 5 | use axum::extract::State; |
6 | use serde_json::{json, Value}; | 6 | use serde_json::{json, Value}; |
7 | use tracing::{debug, info}; | 7 | use tracing::{debug, info, warn}; |
8 | use uuid::Uuid; | 8 | use uuid::Uuid; |
9 | use crate::auth::auth; | 9 | use crate::auth::auth; |
10 | use crate::config::SETTINGS; | 10 | use crate::config::SETTINGS; |
@@ -16,6 +16,7 @@ use crate::services::ping::PingValue; | |||
16 | #[axum_macros::debug_handler] | 16 | #[axum_macros::debug_handler] |
17 | pub async fn start(State(state): State<Arc<crate::AppState>>, headers: HeaderMap, Json(payload): Json<StartPayload>) -> Result<Json<Value>, WebolError> { | 17 | pub 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); | ||
19 | let secret = headers.get("authorization"); | 20 | let secret = headers.get("authorization"); |
20 | let authorized = auth(secret).map_err(WebolError::Auth)?; | 21 | let authorized = auth(secret).map_err(WebolError::Auth)?; |
21 | if authorized { | 22 | if authorized { |
@@ -45,7 +46,7 @@ pub async fn start(State(state): State<Arc<crate::AppState>>, headers: HeaderMap | |||
45 | let uuid_gen = Uuid::new_v4().to_string(); | 46 | let uuid_gen = Uuid::new_v4().to_string(); |
46 | let uuid_genc = uuid_gen.clone(); | 47 | let uuid_genc = uuid_gen.clone(); |
47 | tokio::spawn(async move { | 48 | tokio::spawn(async move { |
48 | debug!("init ping service"); | 49 | debug!("Init ping service"); |
49 | state.ping_map.insert(uuid_gen.clone(), PingValue { ip: device.ip.clone(), online: false }); | 50 | state.ping_map.insert(uuid_gen.clone(), PingValue { ip: device.ip.clone(), online: false }); |
50 | 51 | ||
51 | crate::services::ping::spawn(state.ping_send.clone(), device.ip, uuid_gen.clone(), &state.ping_map).await | 52 | crate::services::ping::spawn(state.ping_send.clone(), device.ip, uuid_gen.clone(), &state.ping_map).await |