Upgrade to axum 0.7, drop 3rd party adapters

This commit is contained in:
Jonathan Kelley committed 2024-02-15 18:05:30 -08:00
1 parent 5dd33c9dcd
commit 214a907adc
53 files changed
+643 -3260

No files matched your search

@@ -8,13 +8,11 @@ publish = false
[dependencies]
dioxus-web = { workspace = true, features = ["hydrate"], optional = true }
dioxus = { workspace = true }
dioxus = { features = ["fullstack"], workspace = true }
dioxus-fullstack = { workspace = true }
axum = { version = "0.6.12", optional = true }
axum = { workspace = true, 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"], optional = true }
tower-http = { workspace = true, features = ["auth"], optional = true }
simple_logger = { version = "4.2.0", optional = true }
async-trait = { version = "0.1.71", optional = true }
sqlx = { version = "0.7.0", features = [
@@ -26,9 +24,12 @@ sqlx = { version = "0.7.0", features = [
"tls-rustls",
"runtime-tokio",
], optional = true }
http = { workspace = true, optional = true }
tower = { workspace = true, optional = true }
serde = "1.0.159"
execute = "0.2.12"
anyhow = "1.0.71"
http = { version = "0.2.9", optional = true }
tower = { version = "0.4.13", optional = true }
[dependencies.axum_session]
version = "0.3.0"
@@ -36,7 +37,7 @@ features = ["sqlite-rustls"]
optional = true
[dependencies.axum_session_auth]
version = "0.3.0"
version = "0.12.0"
features = ["sqlite-rustls"]
optional = true
@@ -17,7 +17,7 @@ use serde::{Deserialize, Serialize};
fn main() {
#[cfg(feature = "web")]
// Hydrate the application on the client
dioxus_web::launch_cfg(app, dioxus_web::Config::new().hydrate(true));
dioxus_web::launch::launch_cfg(app, dioxus_web::Config::new().hydrate(true));
#[cfg(feature = "server")]
{
@@ -51,7 +51,9 @@ fn main() {
// build our application with some routes
let app = Router::new()
// Server side render the application, serve static assets, and register server functions
.serve_dioxus_application("", ServerConfig::new(app, ()))
.serve_dioxus_application("", ServeConfig::builder().build(), || {
VirtualDom::new(app)
})
.layer(
axum_session_auth::AuthSessionLayer::<
crate::auth::User,
@@ -7,8 +7,8 @@ publish = false
[lib]
[dependencies]
dioxus = { workspace = true }
axum = { version = "0.6.12", optional = true }
dioxus = { workspace = true, features = ["launch"] }
axum = { workspace = true, optional = true }
tokio = { workspace = true, features = ["full"], optional = true }
serde = "1.0.159"
@@ -9,5 +9,7 @@ fn main() {
// Set the url of the server where server functions are hosted.
#[cfg(not(feature = "server"))]
dioxus::fullstack::prelude::server_fn::set_server_url("http://127.0.0.1:8080");
dioxus::desktop::launch(app)
#[cfg(feature = "desktop")]
dioxus::prelude::launch_desktop(app)
}
@@ -8,7 +8,7 @@ publish = false
[dependencies]
dioxus = { workspace = true, features = ["router"] }
axum = { version = "0.6.12", optional = true }
axum = { workspace = true, optional = true }
tokio = {workspace = true, features = ["full"], optional = true }
serde = { version = "1.0.159", features = ["derive"] }
@@ -1,4 +0,0 @@
dist
target
static
.dioxus
@@ -1,25 +0,0 @@
[package]
name = "salvo-hello-world"
version = "0.1.0"
edition = "2021"
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 }
serde = "1.0.159"
salvo = { version = "0.63.0", optional = true }
execute = "0.2.12"
reqwest = "0.11.18"
simple_logger = "4.2.0"
tracing-wasm = "0.2.1"
tracing = { workspace = true }
tracing-subscriber = "0.3.17"
[features]
default = []
server = ["salvo", "dioxus-fullstack/salvo"]
web = ["dioxus-web"]
@@ -1,57 +0,0 @@
//! Run with:
//!
//! ```sh
//! dx serve --platform fullstack
//! ```
#![allow(non_snake_case, unused)]
use dioxus::prelude::*;
use dioxus_fullstack::{launch, prelude::*};
use serde::{Deserialize, Serialize};
fn app() -> Element {
let state = use_server_future(move || async move { get_server_data().await.unwrap() })?;
let mut count = use_signal(|| 0);
let mut text = use_signal(|| "...".to_string());
rsx! {
div { "Server state: {state.value().unwrap()}" }
h1 { "High-Five counter: {count}" }
button { onclick: move |_| count += 1, "Up high!" }
button { onclick: move |_| count -= 1, "Down low!" }
button {
onclick: move |_| async move {
if let Ok(data) = get_server_data().await {
println!("Client received: {}", data);
text.set(data.clone());
post_server_data(data).await.unwrap();
}
},
"Run a server function!"
}
"Server said: {text}"
}
}
#[server(PostServerData)]
async fn post_server_data(data: String) -> Result<(), ServerFnError> {
println!("Server received: {}", data);
Ok(())
}
#[server(GetServerData)]
async fn get_server_data() -> Result<String, ServerFnError> {
Ok(reqwest::get("https://httpbin.org/ip").await?.text().await?)
}
fn main() {
#[cfg(feature = "web")]
tracing_wasm::set_as_global_default();
#[cfg(feature = "server")]
tracing_subscriber::fmt::init();
LaunchBuilder::fullstack().launch(app);
}
@@ -1,4 +0,0 @@
dist
target
static
.dioxus
@@ -1,20 +0,0 @@
[package]
name = "warp-hello-world"
version = "0.1.0"
edition = "2021"
publish = false
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies]
dioxus = { workspace = true, features = ["fullstack"] }
serde = "1.0.159"
tracing-wasm = "0.2.1"
tracing = { workspace = true }
tracing-subscriber = "0.3.17"
reqwest = "0.11.18"
[features]
default = []
server = ["dioxus/warp"]
web = ["dioxus/web"]
@@ -1,54 +0,0 @@
//! Run with:
//!
//! ```sh
//! dx serve --platform fullstack
//! ```
#![allow(non_snake_case, unused)]
use dioxus::prelude::*;
fn app() -> Element {
let mut count = use_signal(|| 0);
let text = use_signal(|| "...".to_string());
rsx! {
h1 { "High-Five counter: {count}" }
button { onclick: move |_| count += 1, "Up high!" }
button { onclick: move |_| count -= 1, "Down low!" }
button {
onclick: move |_| {
to_owned![text];
async move {
if let Ok(data) = get_server_data().await {
println!("Client received: {}", data);
text.set(data.clone());
post_server_data(data).await.unwrap();
}
}
},
"Run a server function!"
}
"Server said: {text}"
}
}
#[server]
async fn post_server_data(data: String) -> Result<(), ServerFnError> {
println!("Server received: {}", data);
Ok(())
}
#[server]
async fn get_server_data() -> Result<String, ServerFnError> {
Ok(reqwest::get("https://httpbin.org/ip").await?.text().await?)
}
fn main() {
#[cfg(feature = "web")]
tracing_wasm::set_as_global_default();
#[cfg(feature = "server")]
tracing_subscriber::fmt::init();
launch(app);
}