mirror of
https://github.com/DioxusLabs/dioxus
synced 2025-02-17 06:08:26 +00:00
fix hot reloading in router example
This commit is contained in:
parent
064bee4a9f
commit
3c002913eb
2 changed files with 5 additions and 7 deletions
|
@ -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")))]
|
||||||
|
|
Loading…
Add table
Reference in a new issue