Get more axum stuff upgraded to 0.7

This commit is contained in:
Jonathan Kelley 2024-02-15 18:59:57 -08:00
parent 214a907adc
commit 64a321eacc
No known key found for this signature in database
GPG key ID: 1FBB50F7EB0A08BE
25 changed files with 202 additions and 193 deletions

137
Cargo.lock generated
View file

@ -608,7 +608,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1236b4b292f6c4d6dc34604bb5120d85c3fe1d1aa596bd5cc52ca054d13e7b9e"
dependencies = [
"async-trait",
"axum-core 0.4.3",
"axum-core",
"axum-macros",
"base64",
"bytes",
@ -646,7 +646,7 @@ dependencies = [
"anyhow",
"async-trait",
"axum",
"axum_session 0.3.5",
"axum_session",
"axum_session_auth",
"dioxus",
"dioxus-fullstack",
@ -661,23 +661,6 @@ dependencies = [
"tower-http",
]
[[package]]
name = "axum-core"
version = "0.3.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "759fa577a247914fd3f7f76d62972792636412fbfd634cd452f6a385a74d2d2c"
dependencies = [
"async-trait",
"bytes",
"futures-util",
"http 0.2.11",
"http-body 0.4.6",
"mime",
"rustversion",
"tower-layer",
"tower-service",
]
[[package]]
name = "axum-core"
version = "0.4.3"
@ -709,6 +692,28 @@ dependencies = [
"tokio",
]
[[package]]
name = "axum-extra"
version = "0.9.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "895ff42f72016617773af68fb90da2a9677d89c62338ec09162d4909d86fdd8f"
dependencies = [
"axum",
"axum-core",
"bytes",
"futures-util",
"headers 0.4.0",
"http 1.0.0",
"http-body 1.0.0",
"http-body-util",
"mime",
"pin-project-lite",
"serde",
"tower",
"tower-layer",
"tower-service",
]
[[package]]
name = "axum-hello-world"
version = "0.1.0"
@ -746,53 +751,27 @@ dependencies = [
[[package]]
name = "axum-server"
version = "0.5.1"
version = "0.6.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "447f28c85900215cc1bea282f32d4a2f22d55c5a300afdfbc661c8d6a632e063"
checksum = "c1ad46c3ec4e12f4a4b6835e173ba21c25e484c9d02b49770bf006ce5367c036"
dependencies = [
"arc-swap",
"bytes",
"futures-util",
"http 0.2.11",
"http-body 0.4.6",
"hyper 0.14.28",
"http 1.0.0",
"http-body 1.0.0",
"http-body-util",
"hyper 1.1.0",
"hyper-util",
"pin-project-lite",
"rustls 0.21.10",
"rustls-pemfile 1.0.4",
"rustls-pemfile 2.1.0",
"tokio",
"tokio-rustls 0.24.1",
"tower",
"tower-service",
]
[[package]]
name = "axum_session"
version = "0.3.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2b9a35d2907b706dcd52f875c4f9fe55293ebc03fc5b3c2d8883104c821452b8"
dependencies = [
"aes-gcm",
"async-trait",
"axum-core 0.3.4",
"base64",
"bytes",
"chrono",
"cookie 0.17.0",
"dashmap",
"futures",
"http 0.2.11",
"http-body 0.4.6",
"rand 0.8.5",
"serde",
"serde_json",
"sqlx",
"thiserror",
"tokio",
"tower-layer",
"tower-service",
"tracing",
"uuid",
]
[[package]]
name = "axum_session"
version = "0.12.4"
@ -805,7 +784,7 @@ dependencies = [
"base64",
"bytes",
"chrono",
"cookie 0.18.0",
"cookie",
"dashmap",
"forwarded-header-value",
"futures",
@ -834,8 +813,8 @@ dependencies = [
"anyhow",
"async-recursion",
"async-trait",
"axum-core 0.4.3",
"axum_session 0.12.4",
"axum-core",
"axum_session",
"bytes",
"chrono",
"dashmap",
@ -1699,21 +1678,6 @@ dependencies = [
"unicode-segmentation",
]
[[package]]
name = "cookie"
version = "0.17.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7efb37c3e1ccb1ff97164ad95ac1606e8ccd35b3fa0a7d99a304c7f4a428cc24"
dependencies = [
"aes-gcm",
"base64",
"percent-encoding",
"rand 0.8.5",
"subtle",
"time",
"version_check",
]
[[package]]
name = "cookie"
version = "0.18.0"
@ -2285,6 +2249,7 @@ dependencies = [
"anyhow",
"atty",
"axum",
"axum-extra",
"axum-server",
"cargo-generate",
"cargo_metadata 0.18.1",
@ -2305,7 +2270,7 @@ dependencies = [
"flate2",
"fs_extra",
"futures-util",
"headers",
"headers 0.3.9",
"html_parser",
"hyper 1.1.0",
"hyper-rustls 0.26.0",
@ -4475,13 +4440,28 @@ checksum = "06683b93020a07e3dbcf5f8c0f6d40080d725bea7936fc01ad345c01b97dc270"
dependencies = [
"base64",
"bytes",
"headers-core",
"headers-core 0.2.0",
"http 0.2.11",
"httpdate",
"mime",
"sha1",
]
[[package]]
name = "headers"
version = "0.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "322106e6bd0cba2d5ead589ddb8150a13d7c4217cf80d7c4f682ca994ccc6aa9"
dependencies = [
"base64",
"bytes",
"headers-core 0.3.0",
"http 1.0.0",
"httpdate",
"mime",
"sha1",
]
[[package]]
name = "headers-core"
version = "0.2.0"
@ -4491,6 +4471,15 @@ dependencies = [
"http 0.2.11",
]
[[package]]
name = "headers-core"
version = "0.3.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "54b4a22553d4242c49fddb9ba998a99962b5cc6f22cb5a3482bec22522403ce4"
dependencies = [
"http 1.0.0",
]
[[package]]
name = "heck"
version = "0.3.3"

View file

@ -107,6 +107,7 @@ manganis = { git = "https://github.com/DioxusLabs/collect-assets", rev = "f98269
lru = "0.12.2"
async-trait = "0.1.77"
axum = "0.7.0"
axum-server = "0.6.0"
tower = "0.4.13"
http = "1.0.0"
tower-http = "0.5.1"
@ -114,6 +115,9 @@ hyper = "1.0.0"
hyper-rustls = "0.26.0"
serde_json = "1.0.61"
serde = "1.0.61"
axum_session = "0.12.1"
axum_session_auth = "0.12.1"
axum-extra = "0.9.2"
# This is a "virtual package"
# It is not meant to be published, but is used so "cargo run --example XYZ" works properly

View file

@ -32,14 +32,15 @@ tokio = { version = "1.16.1", features = ["fs", "sync", "rt", "macros"] }
atty = "0.2.14"
chrono = "0.4.19"
anyhow = "1"
hyper = {workspace = true}
hyper-rustls = {workspace = true}
hyper = { workspace = true }
hyper-rustls = { workspace = true }
indicatif = "0.17.5"
subprocess = "0.2.9"
rayon = "1.8.0"
axum = { workspace = true, features = ["ws"] }
axum-server = { version = "0.5.1", features = ["tls-rustls"] }
axum-server = { workspace = true, features = ["tls-rustls"] }
axum-extra = { workspace = true, features = ["typed-header"] }
tower-http = { workspace = true, features = ["full"] }
headers = "0.3.7"

View file

@ -1,10 +1,10 @@
use crate::server::HotReloadState;
use axum::{
extract::{ws::Message, WebSocketUpgrade},
response::IntoResponse,
Extension, TypedHeader,
Extension,
};
use crate::server::HotReloadState;
use axum_extra::TypedHeader;
pub async fn hot_reload_handler(
ws: WebSocketUpgrade,

View file

@ -19,6 +19,7 @@ use axum::{
routing::{get, get_service},
Router,
};
use axum_extra::TypedHeader;
use axum_server::tls_rustls::RustlsConfig;
use dioxus_cli_config::CrateConfig;
use dioxus_cli_config::WebHttpsConfig;
@ -298,7 +299,9 @@ async fn setup_router(
.body(body)
.unwrap()
} else {
response.map(|body| body.into())
response.map(|body| body.try_into().unwrap())
// response.into_body()
// response.map(|body| body.into())
};
let headers = response.headers_mut();
headers.insert(

View file

@ -17,6 +17,7 @@ impl ProxyClient {
fn new(url: Uri) -> Self {
let https = hyper_rustls::HttpsConnectorBuilder::new()
.with_native_roots()
.unwrap()
.https_or_http()
.enable_http1()
.build();
@ -138,7 +139,9 @@ mod test {
.unwrap();
assert_eq!(resp.status(), StatusCode::OK);
assert_eq!(
hyper::body::to_bytes(resp.into_body()).await.unwrap(),
axum::body::to_bytes(resp.into_body(), usize::MAX)
.await
.unwrap(),
"backend: /api"
);
@ -148,7 +151,9 @@ mod test {
.unwrap();
assert_eq!(resp.status(), StatusCode::OK);
assert_eq!(
hyper::body::to_bytes(resp.into_body()).await.unwrap(),
axum::body::to_bytes(resp.into_body(), usize::MAX)
.await
.unwrap(),
"backend: /api/"
);
@ -162,7 +167,9 @@ mod test {
.unwrap();
assert_eq!(resp.status(), StatusCode::OK);
assert_eq!(
hyper::body::to_bytes(resp.into_body()).await.unwrap(),
axum::body::to_bytes(resp.into_body(), usize::MAX)
.await
.unwrap(),
"backend: /api/subpath"
);
backend_handle.abort();

View file

@ -49,8 +49,9 @@ mobile = ["dioxus-mobile", "dioxus-fullstack?/mobile", "dioxus-config-macro/mobi
web = ["dioxus-web", "dioxus-fullstack?/web", "dioxus-config-macro/web", "dioxus-router?/web"]
ssr = ["dioxus-ssr", "dioxus-router?/ssr", "dioxus-config-macro/ssr"]
liveview = ["dioxus-liveview", "dioxus-config-macro/liveview", "dioxus-router?/liveview"]
axum = ["dioxus-fullstack?/axum", "ssr", "dioxus-liveview?/axum"]
axum = ["dioxus-fullstack?/axum", "dioxus-fullstack?/server", "ssr", "dioxus-liveview?/axum"]
tui = ["dioxus-tui", "dioxus-config-macro/tui"]
# This feature just disables the no-renderer-enabled warning
third-party-renderer = []

View file

@ -69,7 +69,24 @@ hot-reload = ["serde_json", "futures-util"]
web = ["dioxus-web", "web-sys"]
desktop = ["dioxus-desktop"]
mobile = ["dioxus-mobile"]
axum = ["dep:axum", "tower-http", "server"]
server = ["server_fn/ssr", "dioxus_server_macro/server", "tokio", "tokio-util", "tokio-stream", "dioxus-ssr", "dioxus-ssr/incremental", "tower", "hyper", "http", "tower-layer", "anymap", "tracing-futures", "pin-project", "thiserror", "dioxus-cli-config"]
default-tls = ["server_fn/default-tls"]
rustls = ["server_fn/rustls"]
axum = ["dep:axum", "tower-http", "server"]
server = [
"server_fn/ssr",
"dioxus_server_macro/server",
"tokio",
"tokio-util",
"tokio-stream",
"dioxus-ssr",
"dioxus-ssr/incremental",
"tower",
"hyper",
"http",
"tower-layer",
"anymap",
"tracing-futures",
"pin-project",
"thiserror",
"dioxus-cli-config"
]

View file

@ -31,13 +31,14 @@ serde = "1.0.159"
execute = "0.2.12"
anyhow = "1.0.71"
[dependencies.axum_session]
version = "0.3.0"
workspace = true
features = ["sqlite-rustls"]
optional = true
[dependencies.axum_session_auth]
version = "0.12.0"
workspace = true
features = ["sqlite-rustls"]
optional = true

View file

@ -44,8 +44,6 @@ fn main() {
.await
.unwrap();
//Create the Database table for storing our Session Data.
session_store.initiate().await.unwrap();
User::create_user_tables(&pool).await;
// build our application with some routes
@ -67,9 +65,9 @@ fn main() {
// run it
let addr = std::net::SocketAddr::from(([127, 0, 0, 1], 3000));
let listener = tokio::net::TcpListener::bind(&addr).await.unwrap();
axum::Server::bind(&addr)
.serve(app.into_make_service())
axum::serve(listener, app.into_make_service())
.await
.unwrap();
});

View file

@ -8,17 +8,19 @@ use dioxus::prelude::*;
#[tokio::main]
async fn main() {
let addr = std::net::SocketAddr::from(([127, 0, 0, 1], 8080));
let listener = tokio::net::TcpListener::bind("127.0.0.01:8080")
.await
.unwrap();
let _ = PostServerData::register_explicit();
let _ = GetServerData::register_explicit();
axum::Server::bind(&addr)
.serve(
axum::Router::new()
.register_server_fns("")
.into_make_service(),
)
.await
.unwrap();
axum::serve(
listener,
axum::Router::new()
.register_server_fns("")
.into_make_service(),
)
.await
.unwrap();
}

View file

@ -7,7 +7,7 @@ publish = false
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies]
dioxus = { workspace = true, features = ["router"] }
dioxus = { workspace = true, features = ["fullstack", "router"] }
axum = { workspace = true, optional = true }
tokio = {workspace = true, features = ["full"], optional = true }
serde = { version = "1.0.159", features = ["derive"] }
@ -16,3 +16,4 @@ serde = { version = "1.0.159", features = ["derive"] }
default = []
server = ["axum", "dioxus/axum"]
web = ["dioxus/web"]

View file

@ -7,21 +7,17 @@
use dioxus::prelude::*;
fn main() {
let config = LaunchBuilder::fullstack();
#[cfg(feature = "server")]
config
.incremental(
IncrementalRendererConfig::default()
.invalidate_after(std::time::Duration::from_secs(120)),
)
.launch();
let cfg = server_only!(dioxus::fullstack::Config::new().incremental(
IncrementalRendererConfig::default().invalidate_after(std::time::Duration::from_secs(120)),
));
#[cfg(not(feature = "server"))]
config.launch(|| {
rsx! {
Router::<Route> {}
}
});
LaunchBuilder::fullstack().with_cfg(cfg).launch(app);
}
fn app() -> Element {
rsx! {
Router::<Route> {}
}
}
#[derive(Clone, Routable, Debug, PartialEq, serde::Serialize, serde::Deserialize)]

View file

@ -15,7 +15,7 @@ use serde::{Deserialize, Serialize};
#[tokio::main]
async fn main() {
pre_cache_static_routes_with_props(
&ServerConfig::new_with_router(
&ServeConfig::new_with_router(
dioxus_fullstack::router::FullstackRouterConfig::<Route>::default(),
)
.assets_path("docs")
@ -37,13 +37,11 @@ fn main() {
);
}
#[cfg(not(any(feature = "web", feature = "server")))]
fn main() {}
#[derive(Clone, Routable, Debug, PartialEq, Serialize, Deserialize)]
enum Route {
#[route("/")]
Home {},
#[route("/blog")]
Blog,
}
@ -72,10 +70,7 @@ fn Home() -> Element {
let text = use_signal(|| "...".to_string());
rsx! {
Link {
to: Route::Blog {},
"Go to blog"
}
Link { to: Route::Blog {}, "Go to blog" }
div {
h1 { "High-Five counter: {count}" }
button { onclick: move |_| count += 1, "Up high!" }

View file

@ -2,7 +2,7 @@
#![doc(html_logo_url = "https://avatars.githubusercontent.com/u/79236386")]
#![doc(html_favicon_url = "https://avatars.githubusercontent.com/u/79236386")]
#![deny(missing_docs)]
#![cfg_attr(any(docsrs, feature = "nightly-doc"), feature(doc_cfg))]
#![cfg_attr(docsrs, feature(doc_cfg))]
pub use once_cell;
@ -10,6 +10,7 @@ mod html_storage;
#[cfg(feature = "server")]
mod adapters;
// Splitting up the glob export lets us document features required for each adapter
#[cfg_attr(docsrs, doc(cfg(feature = "axum")))]
#[cfg(feature = "axum")]
@ -21,45 +22,46 @@ pub use adapters::{server_fn_service, ServerFnHandler};
mod config;
mod hooks;
pub mod launch;
mod server_fn;
#[cfg(all(debug_assertions, feature = "hot-reload", feature = "server"))]
mod hot_reload;
pub mod launch;
pub use config::*;
#[cfg(feature = "server")]
mod layer;
#[cfg(feature = "server")]
mod render;
#[cfg(feature = "server")]
mod serve_config;
#[cfg(feature = "server")]
mod server_context;
mod server_fn;
/// A prelude of commonly used items in dioxus-fullstack.
pub mod prelude {
use crate::hooks;
pub use hooks::{server_cached::server_cached, server_future::use_server_future};
#[cfg(feature = "axum")]
#[cfg_attr(docsrs, doc(cfg(feature = "axum")))]
pub use crate::adapters::axum_adapter::*;
use crate::hooks;
#[cfg(not(feature = "server"))]
#[cfg_attr(
any(docsrs, feature = "nightly-doc"),
doc(cfg(not(feature = "server")))
)]
#[cfg_attr(docsrs, doc(cfg(not(feature = "server"))))]
pub use crate::html_storage::deserialize::get_root_props_from_document;
#[cfg(feature = "server")]
#[cfg_attr(docsrs, doc(cfg(feature = "server")))]
pub use crate::layer::{Layer, Service};
#[cfg(all(feature = "server", feature = "router"))]
#[cfg_attr(
any(docsrs, feature = "nightly-doc"),
doc(cfg(all(feature = "server", feature = "router")))
)]
#[cfg_attr(docsrs, doc(cfg(all(feature = "server", feature = "router"))))]
pub use crate::render::pre_cache_static_routes_with_props;
#[cfg(feature = "server")]
#[cfg_attr(docsrs, doc(cfg(feature = "server")))]
pub use crate::render::SSRState;
@ -71,28 +73,27 @@ pub mod prelude {
#[cfg(feature = "server")]
#[cfg_attr(docsrs, doc(cfg(feature = "server")))]
pub use crate::serve_config::{ServeConfig, ServeConfigBuilder};
#[cfg(all(feature = "server", feature = "axum"))]
#[cfg_attr(
any(docsrs, feature = "nightly-doc"),
doc(cfg(all(feature = "server", feature = "axum")))
)]
#[cfg_attr(docsrs, doc(cfg(all(feature = "server", feature = "axum"))))]
pub use crate::server_context::Axum;
#[cfg(feature = "server")]
#[cfg_attr(docsrs, doc(cfg(feature = "server")))]
pub use crate::server_context::{
extract, server_context, DioxusServerContext, FromServerContext, ProvideServerContext,
};
pub use crate::server_fn::DioxusServerFn;
#[cfg(feature = "server")]
#[cfg_attr(docsrs, doc(cfg(feature = "server")))]
pub use crate::server_fn::{ServerFnMiddleware, ServerFnTraitObj, ServerFunction};
pub use dioxus_server_macro::*;
#[cfg(feature = "server")]
#[cfg_attr(docsrs, doc(cfg(feature = "server")))]
pub use dioxus_ssr::incremental::IncrementalRendererConfig;
pub use server_fn::{self, ServerFn as _, ServerFnError};
pub use hooks::{server_cached::server_cached, server_future::use_server_future};
}
// // Warn users about overlapping features

View file

@ -6,7 +6,6 @@ use dioxus_ssr::{
incremental::{IncrementalRendererConfig, RenderFreshness, WrapBody},
Renderer,
};
use serde::Serialize;
use std::sync::Arc;
use std::sync::RwLock;
use tokio::task::spawn_blocking;
@ -28,7 +27,6 @@ impl SsrRendererPool {
server_context: &DioxusServerContext,
) -> Result<(RenderFreshness, String), dioxus_ssr::incremental::IncrementalRendererError> {
let wrapper = FullstackRenderer {
serialized_props: None,
cfg: cfg.clone(),
server_context: server_context.clone(),
};
@ -210,7 +208,6 @@ impl SSRState {
}
struct FullstackRenderer {
serialized_props: Option<String>,
cfg: ServeConfig,
server_context: DioxusServerContext,
}

View file

@ -1,14 +1,10 @@
#![allow(non_snake_case)]
//! Configeration for how to serve a Dioxus application
//! Configuration for how to serve a Dioxus application
#[cfg(feature = "router")]
use crate::router::*;
use std::fs::File;
use std::io::Read;
use std::path::PathBuf;
use dioxus_lib::prelude::*;
/// A ServeConfig is used to configure how to serve a Dioxus application. It contains information about how to serve static assets, and what content to render with [`dioxus-ssr`].
#[derive(Clone)]
pub struct ServeConfigBuilder {

View file

@ -1,5 +1,4 @@
use crate::html_storage::HTMLData;
pub use server_fn_impl::*;
use std::sync::Arc;
use std::sync::RwLock;

View file

@ -1,19 +1,17 @@
use std::{
io::{BufRead, BufReader, Write},
io::Write,
path::PathBuf,
str::FromStr,
sync::{Arc, Mutex},
};
use crate::HotReloadMsg;
use dioxus_core::Template;
use dioxus_rsx::{
hot_reload::{FileMap, FileMapBuildResult, UpdateResult},
HotReloadingContext,
};
use interprocess_docfix::local_socket::{LocalSocketListener, LocalSocketStream};
use interprocess_docfix::local_socket::LocalSocketListener;
use notify::{RecommendedWatcher, RecursiveMode, Watcher};
use serde::{Deserialize, Serialize};
#[cfg(feature = "file_watcher")]
use dioxus_html::HtmlCtx;

View file

@ -23,8 +23,8 @@ async fn main() {
println!("Listening on http://{addr}");
axum::Server::bind(&addr.to_string().parse().unwrap())
.serve(app.into_make_service())
let listener = tokio::net::TcpListener::bind(&addr).await.unwrap();
axum::serve(listener, app.into_make_service())
.await
.unwrap();
}

View file

@ -55,8 +55,8 @@ async fn main() {
println!("Listening on http://{addr}");
axum::Server::bind(&addr.to_string().parse().unwrap())
.serve(app.into_make_service())
let listener = tokio::net::TcpListener::bind(&addr).await.unwrap();
axum::serve(listener, app.into_make_service())
.await
.unwrap();
}

View file

@ -57,8 +57,8 @@ async fn main() {
println!("Listening on http://{addr}");
axum::Server::bind(&addr.to_string().parse().unwrap())
.serve(app.into_make_service())
let listener = tokio::net::TcpListener::bind(&addr).await.unwrap();
axum::serve(listener, app.into_make_service())
.await
.unwrap();
}

View file

@ -45,6 +45,7 @@ pub fn criterion_benchmark(c: &mut Criterion) {
})
})
});
c.bench_function("build 1000 routes no memory cache", |b| {
b.to_async(tokio::runtime::Runtime::new().unwrap())
.iter(|| async {
@ -67,6 +68,7 @@ pub fn criterion_benchmark(c: &mut Criterion) {
.memory_cache_limit(0)
.invalidate_after(Duration::from_secs(10))
.build();
for id in 0..1000 {
render_route(
&mut renderer,

View file

@ -33,8 +33,11 @@ async fn main() {
println!("Listening on http://{listen_address}");
axum::Server::bind(&listen_address.to_string().parse().unwrap())
.serve(app.into_make_service())
let listener = tokio::net::TcpListener::bind(&listen_address)
.await
.unwrap();
axum::serve(listener, app.into_make_service())
.await
.unwrap();
}

View file

@ -122,38 +122,36 @@ where
<R as std::str::FromStr>::Err: std::fmt::Display,
{
// If we're on the web and have wasm, use the web history provider
if cfg!(all(target_arch = "wasm32", feature = "web")) {
return Box::new(AnyHistoryProviderImplWrapper::new(
WebHistory::<R>::default(),
));
}
#[cfg(all(target_arch = "wasm32", feature = "web"))]
return Box::new(AnyHistoryProviderImplWrapper::new(
WebHistory::<R>::default(),
));
// If we're using fullstack and server side rendering, use the memory history provider
if cfg!(all(feature = "fullstack", feature = "ssr")) {
return Box::new(AnyHistoryProviderImplWrapper::new(
MemoryHistory::<R>::with_initial_path(
dioxus_fullstack::prelude::server_context()
.request_parts()
.unwrap()
.uri
.to_string()
.parse()
.unwrap_or_else(|err| {
tracing::error!("Failed to parse uri: {}", err);
"/".parse().unwrap_or_else(|err| {
panic!("Failed to parse uri: {}", err);
})
}),
),
));
}
#[cfg(all(feature = "fullstack", feature = "ssr"))]
return Box::new(AnyHistoryProviderImplWrapper::new(
MemoryHistory::<R>::with_initial_path(
dioxus_fullstack::prelude::server_context()
.request_parts()
.unwrap()
.uri
.to_string()
.parse()
.unwrap_or_else(|err| {
tracing::error!("Failed to parse uri: {}", err);
"/".parse().unwrap_or_else(|err| {
panic!("Failed to parse uri: {}", err);
})
}),
),
));
// If liveview is enabled, use the liveview history provider
if cfg!(feature = "liveview") {
return Box::new(AnyHistoryProviderImplWrapper::new(
LiveviewHistory::new_with_initial_path(initial_route),
));
}
#[cfg(feature = "liveview")]
return Box::new(AnyHistoryProviderImplWrapper::new(
LiveviewHistory::new_with_initial_path(initial_route),
));
// If none of the above, use the memory history provider, which is a decent enough fallback
// Eventually we want to integrate with the mobile history provider, and other platform providers