Skip to content

Commit f656ef9

Browse files
committed
feat: migrate serve WebSocket from ws crate to Axum
Migrates the live reload WebSocket server from the standalone `ws` crate to native Axum WebSocket support: - Replace ws::WebSocket with axum's built-in WebSocket extractor - Use tokio::sync::broadcast for message broadcasting to clients - Integrate WebSocket endpoint into main Axum router at /livereload - Serve livereload.js via dedicated route instead of fallback handler - Remove separate WebSocket server thread (now runs on same port as HTTP) Also fixes build error notification via WebSocket: - Send reload message on build errors so browser auto-refreshes - Handle 404 responses in error_injection_middleware for error display - Include livereload.js in error page so it can reload when fixed - Don't interfere with WebSocket upgrades (101) in middleware Additional improvements: - Add WebSocket ping/pong keepalive (30s interval) for connection health - Add graceful shutdown support via with_graceful_shutdown() - Handle Message::Close and Message::Pong explicitly in WebSocket handler - Remove unnecessary #[derive(Clone)] from AppState (already Arc-wrapped) Cleanup of vestigial ws_port code: - Remove ws_port parameter from create_new_site() function signature - Simplify enable_live_reload_with_port() to use interface_port directly - Update both call sites in serve() to remove the None argument - Update test helper to remove ws_port parameter - Fix test assertion to verify live_reload uses interface_port Dependencies: - Add "ws" feature to axum for WebSocket support - Add "sync" feature to tokio for broadcast channels - Remove ws, tower, tower-http, tracing, tracing-subscriber crates
1 parent f15a7a9 commit f656ef9

File tree

3 files changed

+288
-464
lines changed

3 files changed

+288
-464
lines changed

0 commit comments

Comments
 (0)