switch to launch builder instead of macro for fullstack
This commit is contained in:
1 parent
cfd62e274e
commit
9f891f9478
13 files changed
+259
-193
No files matched your search
@@ -73,7 +73,7 @@ fn main() {
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
fn app(cx: Scope) -> Element {
|
||||
let user_name = use_state(cx, || "?".to_string());
|
||||
let permissions = use_state(cx, || "?".to_string());
|
||||
|
||||
@@ -10,8 +10,8 @@ use dioxus_fullstack::prelude::*;
|
||||
async fn main() {
|
||||
let addr = std::net::SocketAddr::from(([127, 0, 0, 1], 8080));
|
||||
|
||||
PostServerData::register_explicit();
|
||||
GetServerData::register_explicit();
|
||||
let _ = PostServerData::register_explicit();
|
||||
let _ = GetServerData::register_explicit();
|
||||
|
||||
axum::Server::bind(&addr)
|
||||
.serve(
|
||||
|
||||
@@ -7,14 +7,10 @@ publish = false
|
||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||
|
||||
[dependencies]
|
||||
dioxus-web = { workspace = true, features = ["hydrate"], optional = true }
|
||||
dioxus = { workspace = true }
|
||||
dioxus-fullstack = { workspace = true }
|
||||
axum = { version = "0.6.12", optional = true }
|
||||
tokio = { workspace = true, features = ["full"], optional = true }
|
||||
serde = "1.0.159"
|
||||
execute = "0.2.12"
|
||||
tower-http = { version = "0.4.1", features = ["auth"] }
|
||||
simple_logger = "4.2.0"
|
||||
wasm-logger = "0.2.0"
|
||||
log.workspace = true
|
||||
@@ -22,5 +18,5 @@ reqwest = "0.11.18"
|
||||
|
||||
[features]
|
||||
default = []
|
||||
ssr = ["axum", "tokio", "dioxus-fullstack/axum"]
|
||||
web = ["dioxus-web"]
|
||||
ssr = ["axum", "dioxus-fullstack/axum"]
|
||||
web = ["dioxus-fullstack/web"]
|
||||
@@ -7,8 +7,12 @@
|
||||
|
||||
#![allow(non_snake_case, unused)]
|
||||
use dioxus::prelude::*;
|
||||
use dioxus_fullstack::{launch, prelude::*};
|
||||
use dioxus_fullstack::{
|
||||
launch::{self, LaunchBuilder},
|
||||
prelude::*,
|
||||
};
|
||||
use serde::{Deserialize, Serialize};
|
||||
use wasm_logger::Config;
|
||||
|
||||
#[derive(Props, PartialEq, Debug, Default, Serialize, Deserialize, Clone)]
|
||||
struct AppProps {
|
||||
@@ -66,7 +70,5 @@ fn main() {
|
||||
#[cfg(feature = "ssr")]
|
||||
simple_logger::SimpleLogger::new().init().unwrap();
|
||||
|
||||
launch!(@([127, 0, 0, 1], 8080), app, {
|
||||
serve_cfg: ServeConfigBuilder::new(app, AppProps { count: 0 }),
|
||||
});
|
||||
LaunchBuilder::new_with_props(app, AppProps { count: 0 }).launch()
|
||||
}
|
||||
@@ -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 {},
|
||||
|
||||
@@ -64,7 +64,5 @@ fn main() {
|
||||
#[cfg(feature = "ssr")]
|
||||
simple_logger::SimpleLogger::new().init().unwrap();
|
||||
|
||||
launch!(@([127, 0, 0, 1], 8080), app, {
|
||||
serve_cfg: ServeConfigBuilder::new(app, AppProps { count: 0 }),
|
||||
});
|
||||
LaunchBuilder::new_with_props(app, AppProps { count: 0 }).launch()
|
||||
}
|
||||
@@ -64,7 +64,5 @@ fn main() {
|
||||
#[cfg(feature = "ssr")]
|
||||
simple_logger::SimpleLogger::new().init().unwrap();
|
||||
|
||||
launch!(@([127, 0, 0, 1], 8080), app, {
|
||||
serve_cfg: ServeConfigBuilder::new(app, AppProps { count: 0 }),
|
||||
});
|
||||
LaunchBuilder::new_with_props(app, AppProps { count: 0 }).launch()
|
||||
}
|
||||
Reference in new issue
Block a user