use std::net::SocketAddr; use axum::extract::ws::WebSocketUpgrade; use axum::extract::ConnectInfo; use axum::response::IntoResponse; use axum_extra::{headers, TypedHeader}; use library::context::Context; use macros::ws; use crate::service::websocket_service; #[ws("/ws")] pub async fn websocket_handler( context: Context, ws: WebSocketUpgrade, user_agent: Option>, ConnectInfo(addr): ConnectInfo ) -> impl IntoResponse { tracing::info!("`{:?}` at {:?} connected.", user_agent, addr); ws.on_upgrade(move |socket| websocket_service::handle_socket(socket, addr, context)) }