fix hot reloading in router example

This commit is contained in:
Evan Almloff 2023-05-01 17:38:17 -05:00
parent 064bee4a9f
commit 3c002913eb
2 changed files with 5 additions and 7 deletions

View file

@ -50,6 +50,8 @@ fn main() {
axum::Router::new()
// Register server functions
.register_server_fns("")
// Connect to the hot reload server
.connect_hot_reload()
// Serve the static assets folder
.nest_service("/assets", serve_dir)
// If the path is unknown, render the application

View file

@ -290,15 +290,10 @@ where
self.nest(
"/_dioxus",
Router::new()
.route("/hot_reload", get(hot_reload_handler))
.route(
"/disconnect",
get(|ws: WebSocketUpgrade| async {
ws.on_failed_upgrade(|error| {
println!("failed to upgrade: {}", error);
todo!()
})
.on_upgrade(|mut ws| async move {
ws.on_upgrade(|mut ws| async move {
use axum::extract::ws::Message;
let _ = ws.send(Message::Text("connected".into())).await;
loop {
@ -308,7 +303,8 @@ where
}
})
}),
),
)
.route("/hot_reload", get(hot_reload_handler)),
)
}
#[cfg(not(all(debug_assertions, feature = "hot-reload", feature = "ssr")))]