switch to launch builder instead of macro for fullstack

This commit is contained in:
Evan Almloff committed 2023-07-28 12:58:34 -07:00
1 parent cfd62e274e
commit 9f891f9478
13 files changed
+259 -193

No files matched your search

@@ -9,7 +9,7 @@ publish = false
[dependencies]
dioxus-web = { workspace = true, features = ["hydrate"], optional = true }
dioxus = { workspace = true }
dioxus-router = { workspace = true}
dioxus-router = { workspace = true }
dioxus-fullstack = { workspace = true, features = ["router"] }
axum = { version = "0.6.12", optional = true }
tokio = {workspace = true, features = ["full"], optional = true }
@@ -17,5 +17,5 @@ serde = { version = "1.0.159", features = ["derive"] }
[features]
default = []
ssr = ["axum", "tokio", "dioxus-fullstack/axum"]
web = ["dioxus-web", "dioxus-router/web"]
ssr = ["axum", "dioxus-fullstack/axum"]
web = ["dioxus-fullstack/web", "dioxus-router/web"]
@@ -12,12 +12,20 @@ use dioxus_fullstack::prelude::*;
use dioxus_router::prelude::*;
fn main() {
launch_router!(@([127, 0, 0, 1], 8080), Route, {
incremental: IncrementalRendererConfig::default().invalidate_after(std::time::Duration::from_secs(120)),
});
let config = LaunchBuilder::<FullstackRouterConfig<Route>>::router();
#[cfg(feature = "ssr")]
config
.incremental(
IncrementalRendererConfig::default()
.invalidate_after(std::time::Duration::from_secs(120)),
)
.launch();
#[cfg(not(feature = "ssr"))]
config.launch();
}
#[derive(Clone, Routable, Debug, PartialEq)]
#[derive(Clone, Routable, Debug, PartialEq, serde::Serialize, serde::Deserialize)]
enum Route {
#[route("/")]
Home {},