| Crates.io | rustapi-ws |
| lib.rs | rustapi-ws |
| version | 0.1.207 |
| created_at | 2026-01-05 20:43:22.821265+00 |
| updated_at | 2026-01-26 00:03:40.57112+00 |
| description | WebSocket support for RustAPI - Real-time bidirectional communication |
| homepage | |
| repository | https://github.com/Tuntii/RustAPI |
| max_upload_size | |
| id | 2024547 |
| size | 148,875 |
Real-time bidirectional communication made simple.
Built on tokio-tungstenite, this crate provides a first-class WebSocket extractor for RustAPI.
use rustapi_ws::{WebSocket, Message};
#[get("/chat")]
async fn chat_handler(ws: WebSocket) -> impl Responder {
ws.on_upgrade(handle_socket)
}
async fn handle_socket(mut socket: WebSocket) {
while let Some(Ok(msg)) = socket.recv().await {
if let Message::Text(text) = msg {
println!("Received: {}", text);
socket.send(Message::Text("Echo!".into())).await.unwrap();
}
}
}