fix hot reloading in router example
This commit is contained in:
1 parent
064bee4a9f
commit
3c002913eb
2 files changed
+5
-7
No files matched your search
@@ -50,6 +50,8 @@ fn main() {
|
|||||||
axum::Router::new()
|
axum::Router::new()
|
||||||
// Register server functions
|
// Register server functions
|
||||||
.register_server_fns("")
|
.register_server_fns("")
|
||||||
|
// Connect to the hot reload server
|
||||||
|
.connect_hot_reload()
|
||||||
// Serve the static assets folder
|
// Serve the static assets folder
|
||||||
.nest_service("/assets", serve_dir)
|
.nest_service("/assets", serve_dir)
|
||||||
// If the path is unknown, render the application
|
// If the path is unknown, render the application
|
||||||
|
|||||||
@@ -290,15 +290,10 @@ where
|
|||||||
self.nest(
|
self.nest(
|
||||||
"/_dioxus",
|
"/_dioxus",
|
||||||
Router::new()
|
Router::new()
|
||||||
.route("/hot_reload", get(hot_reload_handler))
|
|
||||||
.route(
|
.route(
|
||||||
"/disconnect",
|
"/disconnect",
|
||||||
get(|ws: WebSocketUpgrade| async {
|
get(|ws: WebSocketUpgrade| async {
|
||||||
ws.on_failed_upgrade(|error| {
|
ws.on_upgrade(|mut ws| async move {
|
||||||
println!("failed to upgrade: {}", error);
|
|
||||||
todo!()
|
|
||||||
})
|
|
||||||
.on_upgrade(|mut ws| async move {
|
|
||||||
use axum::extract::ws::Message;
|
use axum::extract::ws::Message;
|
||||||
let _ = ws.send(Message::Text("connected".into())).await;
|
let _ = ws.send(Message::Text("connected".into())).await;
|
||||||
loop {
|
loop {
|
||||||
@@ -308,7 +303,8 @@ where
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
}),
|
}),
|
||||||
),
|
)
|
||||||
|
.route("/hot_reload", get(hot_reload_handler)),
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
#[cfg(not(all(debug_assertions, feature = "hot-reload", feature = "ssr")))]
|
#[cfg(not(all(debug_assertions, feature = "hot-reload", feature = "ssr")))]
|
||||||
|
|||||||
Reference in new issue
Block a user