handler-id

This commit is contained in:
Untone 2023-10-18 14:59:01 +03:00
parent c11004aaef
commit 6c0f84749e
3 changed files with 5 additions and 1 deletions

1
Cargo.lock generated
View File

@ -459,6 +459,7 @@ version = "0.2.14"
dependencies = [ dependencies = [
"actix-web", "actix-web",
"futures", "futures",
"rand",
"redis", "redis",
"reqwest", "reqwest",
"serde", "serde",

View File

@ -13,6 +13,7 @@ serde = { version = "1.0", features = ["derive"] }
serde_json = "1.0" serde_json = "1.0"
reqwest = { version = "0.11", features = ["json"] } reqwest = { version = "0.11", features = ["json"] }
futures = "0.3.28" futures = "0.3.28"
rand = "0.8.5"
[[bin]] [[bin]]
name = "presence" name = "presence"

View File

@ -28,6 +28,8 @@ async fn connect_handler(
req: HttpRequest, req: HttpRequest,
state: web::Data<AppState>, state: web::Data<AppState>,
) -> Result<HttpResponse, actix_web::Error> { ) -> Result<HttpResponse, actix_web::Error> {
let handler_id: u64 = rand::random();
let token = match req.headers().get("Authorization") { let token = match req.headers().get("Authorization") {
Some(val) => val.to_str().unwrap_or("").split(" ").last().unwrap_or(""), Some(val) => val.to_str().unwrap_or("").split(" ").last().unwrap_or(""),
None => match req.match_info().get("token") { None => match req.match_info().get("token") {
@ -112,7 +114,7 @@ async fn connect_handler(
}); });
break; break;
} else { } else {
println!("[handler] message handled {}", message_str); println!("[handler {}] message handled {}", handler_id, message_str);
} }
}; };
} }