Skip to content
Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
383 changes: 222 additions & 161 deletions Cargo.lock

Large diffs are not rendered by default.

7 changes: 4 additions & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@ tauri-utils = { version = "=2.1.1" }
tauri-bundler = { version = "=2.2.3" }
lru = "0.12.2"
async-trait = "0.1.77"
axum = { version = "0.7.0", default-features = false }
axum = "0.8.1"
axum-server = { version = "0.7.1", default-features = false }
tower = "0.4.13"
http = "1.0.0"
Expand All @@ -222,8 +222,9 @@ serde = "1.0.61"
syn = "2.0"
quote = "1.0"
proc-macro2 = "1.0"
axum_session = "0.12.1"
axum_session_auth = "0.12.1"
axum_session = "0.16.0"
axum_session_auth = "0.16.0"
axum_session_sqlx = "0.5.0"
axum-extra = "0.9.2"
reqwest = "0.12.5"
owo-colors = "4.0.0"
Expand Down
10 changes: 7 additions & 3 deletions examples/fullstack-auth/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ axum = { workspace = true, optional = true }
tokio = { workspace = true, features = ["full"], optional = true }
tower-http = { workspace = true, features = ["auth"], optional = true }
async-trait = { version = "0.1.71", optional = true }
sqlx = { version = "0.7.0", features = [
sqlx = { version = "0.8.2", features = [
"macros",
"migrate",
"postgres",
Expand All @@ -34,12 +34,15 @@ anyhow = { workspace = true }

[dependencies.axum_session]
workspace = true
features = ["sqlite-rustls"]
optional = true

[dependencies.axum_session_auth]
workspace = true
features = ["sqlite-rustls"]
optional = true

[dependencies.axum_session_sqlx]
workspace = true
features = ["sqlite"]
optional = true

[features]
Expand All @@ -54,6 +57,7 @@ server = [
"sqlx",
"axum_session",
"axum_session_auth",
"axum_session_sqlx",
"http",
"tower",
]
Expand Down
11 changes: 4 additions & 7 deletions examples/fullstack-auth/src/auth.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,9 @@ use axum::{
routing::get,
Router,
};
use axum_session::{SessionConfig, SessionLayer, SessionSqlitePool, SessionStore};
use axum_session::{SessionConfig, SessionLayer, SessionStore};
use axum_session_auth::*;
use axum_session_sqlx::SessionSqlitePool;
use core::pin::Pin;
use dioxus_fullstack::prelude::*;
use serde::{Deserialize, Serialize};
Expand Down Expand Up @@ -192,12 +193,8 @@ pub async fn connect_to_database() -> SqlitePool {
.unwrap()
}

pub type Session = axum_session_auth::AuthSession<
crate::auth::User,
i64,
axum_session_auth::SessionSqlitePool,
sqlx::SqlitePool,
>;
pub type Session =
axum_session_auth::AuthSession<crate::auth::User, i64, SessionSqlitePool, sqlx::SqlitePool>;

pub async fn get_session() -> Result<Session, ServerFnError> {
extract::<Session, _>()
Expand Down
4 changes: 2 additions & 2 deletions examples/fullstack-auth/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ fn main() {
use axum_session::SessionConfig;
use axum_session::SessionStore;
use axum_session_auth::AuthConfig;
use axum_session_auth::SessionSqlitePool;
use axum_session_sqlx::SessionSqlitePool;
tokio::runtime::Runtime::new()
.unwrap()
.block_on(async move {
Expand All @@ -49,7 +49,7 @@ fn main() {
axum_session_auth::AuthSessionLayer::<
crate::auth::User,
i64,
axum_session_auth::SessionSqlitePool,
SessionSqlitePool,
sqlx::SqlitePool,
>::new(Some(pool))
.with_config(auth_config),
Expand Down
4 changes: 2 additions & 2 deletions packages/cli/src/serve/proxy.rs
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ pub(crate) fn add_proxy(mut router: Router, proxy: &WebProxyConfig) -> Result<Ro

// api/*path
router = router.route(
&format!("/{}/*path", trimmed_path.trim_end_matches('/')),
&format!("/{}/{{*path}}", trimmed_path.trim_end_matches('/')),
method_router.clone(),
);

Expand Down Expand Up @@ -190,7 +190,7 @@ mod test {
async fn setup_servers(mut config: WebProxyConfig) -> String {
let backend_router =
Router::new().route(
"/*path",
"/{*path}",
any(|request: axum::extract::Request| async move {
format!("backend: {}", request.uri())
}),
Expand Down
29 changes: 20 additions & 9 deletions packages/cli/src/serve/server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -211,8 +211,8 @@ impl WebServer {
}

self.send_shutdown().await;
for socket in self.hot_reload_sockets.drain(..) {
_ = socket.close().await;
for mut socket in self.hot_reload_sockets.drain(..) {
_ = socket.send(Message::Close(None)).await;
}
}

Expand Down Expand Up @@ -302,7 +302,11 @@ impl WebServer {
let mut i = 0;
while i < self.hot_reload_sockets.len() {
let socket = &mut self.hot_reload_sockets[i];
if socket.send(Message::Text(msg.clone())).await.is_err() {
if socket
.send(Message::Text(msg.clone().into()))
.await
.is_err()
{
self.hot_reload_sockets.remove(i);
} else {
i += 1;
Expand Down Expand Up @@ -343,7 +347,7 @@ impl WebServer {
async fn send_devserver_message(&mut self, msg: DevserverMsg) {
for socket in self.hot_reload_sockets.iter_mut() {
_ = socket
.send(Message::Text(serde_json::to_string(&msg).unwrap()))
.send(Message::Text(serde_json::to_string(&msg).unwrap().into()))
.await;
}
}
Expand Down Expand Up @@ -393,7 +397,11 @@ async fn devserver_mainloop(

// If we're not using rustls, just use regular axum
if https_cfg.enabled != Some(true) {
axum::serve(listener.try_into().unwrap(), router.into_make_service()).await?;
axum::serve(
tokio::net::TcpListener::from_std(listener).unwrap(),
router.into_make_service(),
)
.await?;
return Ok(());
}

Expand Down Expand Up @@ -434,7 +442,7 @@ fn build_devserver_router(
// For fullstack, liveview, and server, forward all requests to the inner server
let address = fullstack_address.unwrap();
tracing::debug!("Proxying requests to fullstack server at {address}");
router = router.nest_service("/",super::proxy::proxy_to(
router = router.fallback_service(super::proxy::proxy_to(
format!("http://{address}").parse().unwrap(),
true,
|error| {
Expand All @@ -461,8 +469,11 @@ fn build_devserver_router(
.unwrap_or_default()
.trim_matches('/')
);

router = router.nest_service(&base_path, build_serve_dir(args, krate));
if base_path == "/" {
router = router.fallback_service(build_serve_dir(args, krate));
} else {
router = router.nest_service(&base_path, build_serve_dir(args, krate));
}
}

// Setup middleware to intercept html requests if the build status is "Building"
Expand Down Expand Up @@ -755,6 +766,6 @@ impl SharedStatus {

async fn send_to(&self, socket: &mut WebSocket) -> Result<(), axum::Error> {
let msg = serde_json::to_string(&self.get()).unwrap();
socket.send(Message::Text(msg)).await
socket.send(Message::Text(msg.into())).await
}
}
2 changes: 1 addition & 1 deletion packages/fullstack/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ resolver = "2"

[dependencies]
# server functions
server_fn = { version = "0.7.3", features = ["json", "url", "browser"], default-features = false }
server_fn = { version = "0.8.0-rc1", features = ["browser"], default-features = false }
dioxus_server_macro = { workspace = true }

# axum
Expand Down
4 changes: 2 additions & 2 deletions packages/liveview/src/adapters/axum_adapter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,12 @@ fn transform_rx(message: Result<Message, axum::Error>) -> Result<Vec<u8>, LiveVi
message
.map_err(|_| LiveViewError::SendingFailed)?
.into_text()
.map(|s| s.into_bytes())
.map(|s| s.as_str().into())
.map_err(|_| LiveViewError::SendingFailed)
}

async fn transform_tx(message: Vec<u8>) -> Result<Message, axum::Error> {
Ok(Message::Binary(message))
Ok(Message::Binary(message.into()))
}

impl LiveviewRouter for Router {
Expand Down
34 changes: 19 additions & 15 deletions packages/playwright-tests/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion packages/playwright-tests/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,6 @@
"author": "",
"license": "ISC",
"devDependencies": {
"@playwright/test": "^1.42.1"
"@playwright/test": "^1.51.0"
}
}
2 changes: 1 addition & 1 deletion packages/server-macro/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ description = "Server function macros for Dioxus"
proc-macro2 = "^1.0.63"
quote = "^1.0.26"
syn = { workspace = true, features = ["full"] }
server_fn_macro = { version = "0.7.3" }
server_fn_macro = "0.8.0-rc1"

[dev-dependencies]
dioxus = { workspace = true, features = ["fullstack"] }
Expand Down
Loading
Loading