Get more axum stuff upgraded to 0.7
This commit is contained in:
25 files changed
+202
-193
No files matched your search
@@ -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,
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in new issue
Block a user