diff --git a/examples/errors_axum/src/main.rs b/examples/errors_axum/src/main.rs index 778e060c8..4783ab6ff 100644 --- a/examples/errors_axum/src/main.rs +++ b/examples/errors_axum/src/main.rs @@ -28,7 +28,7 @@ async fn custom_handler( move || { provide_context(id.clone()); }, - || view! { }, + App, ); handler(req).await.into_response() } @@ -48,13 +48,13 @@ async fn main() { let conf = get_configuration(None).await.unwrap(); let leptos_options = conf.leptos_options; let addr = leptos_options.site_addr; - let routes = generate_route_list(|| view! { }).await; + let routes = generate_route_list(App); // build our application with a route let app = Router::new() .route("/api/*fn_name", post(leptos_axum::handle_server_fns)) .route("/special/:id", get(custom_handler)) - .leptos_routes(&leptos_options, routes, || view! { }) + .leptos_routes(&leptos_options, routes, App) .fallback(file_and_error_handler) .with_state(leptos_options); diff --git a/examples/hackernews_axum/src/main.rs b/examples/hackernews_axum/src/main.rs index 849385ef9..786fad53f 100644 --- a/examples/hackernews_axum/src/main.rs +++ b/examples/hackernews_axum/src/main.rs @@ -18,7 +18,7 @@ if #[cfg(feature = "ssr")] { let conf = get_configuration(Some("Cargo.toml")).await.unwrap(); let leptos_options = conf.leptos_options; let addr = leptos_options.site_addr; - let routes = generate_route_list(|| view! { }).await; + let routes = generate_route_list(App); simple_logger::init_with_level(log::Level::Debug).expect("couldn't initialize logging"); diff --git a/examples/hackernews_islands_axum/Cargo.toml b/examples/hackernews_islands_axum/Cargo.toml index 698ae5648..fcbee56b7 100644 --- a/examples/hackernews_islands_axum/Cargo.toml +++ b/examples/hackernews_islands_axum/Cargo.toml @@ -1,5 +1,5 @@ [package] -name = "hackernews" +name = "hackernews_islands" version = "0.1.0" edition = "2021" diff --git a/examples/hackernews_islands_axum/src/main.rs b/examples/hackernews_islands_axum/src/main.rs index 119975687..34696c2c8 100644 --- a/examples/hackernews_islands_axum/src/main.rs +++ b/examples/hackernews_islands_axum/src/main.rs @@ -1,7 +1,7 @@ #[cfg(feature = "ssr")] mod ssr_imports { pub use axum::{routing::get, Router}; - pub use hackernews::fallback::file_and_error_handler; + pub use hackernews_islands::fallback::file_and_error_handler; pub use leptos::*; pub use leptos_axum::{generate_route_list, LeptosRoutes}; pub use tower_http::{compression::CompressionLayer, services::ServeFile}; @@ -10,18 +10,18 @@ mod ssr_imports { #[cfg(feature = "ssr")] #[tokio::main] async fn main() { - use hackernews::*; + use hackernews_islands::*; use ssr_imports::*; let conf = get_configuration(Some("Cargo.toml")).await.unwrap(); let leptos_options = conf.leptos_options; let addr = leptos_options.site_addr; - let routes = generate_route_list(|| view! { }).await; + let routes = generate_route_list(App); // build our application with a route let app = Router::new() .route("/favicon.ico", get(file_and_error_handler)) - .leptos_routes(&leptos_options, routes, || view! { }) + .leptos_routes(&leptos_options, routes, App) .fallback(file_and_error_handler) .with_state(leptos_options); @@ -37,7 +37,7 @@ async fn main() { // client-only stuff for Trunk #[cfg(not(feature = "ssr"))] pub fn main() { - use hackernews::*; + use hackernews_islands::*; use leptos::*; _ = console_log::init_with_level(log::Level::Debug); console_error_panic_hook::set_once(); diff --git a/examples/leptos-tailwind-axum/src/main.rs b/examples/leptos-tailwind-axum/src/main.rs index aafe0cb1b..0bed160c5 100644 --- a/examples/leptos-tailwind-axum/src/main.rs +++ b/examples/leptos-tailwind-axum/src/main.rs @@ -19,7 +19,7 @@ async fn main() { let addr = conf.leptos_options.site_addr; let leptos_options = conf.leptos_options; // Generate the list of routes in your Leptos App - let routes = generate_route_list(|| view! { }).await; + let routes = generate_route_list(App); // build our application with a route let app = Router::new() diff --git a/examples/session_auth_axum/src/main.rs b/examples/session_auth_axum/src/main.rs index f9b91f9fd..42dffc341 100644 --- a/examples/session_auth_axum/src/main.rs +++ b/examples/session_auth_axum/src/main.rs @@ -16,7 +16,7 @@ if #[cfg(feature = "ssr")] { use session_auth_axum::state::AppState; use session_auth_axum::fallback::file_and_error_handler; use leptos_axum::{generate_route_list, LeptosRoutes, handle_server_fns_with_context}; - use leptos::{logging::log, view, provide_context, get_configuration}; + use leptos::{logging::log, provide_context, get_configuration}; use sqlx::{SqlitePool, sqlite::SqlitePoolOptions}; use axum_session::{SessionConfig, SessionLayer, SessionStore}; use axum_session_auth::{AuthSessionLayer, AuthConfig, SessionSqlitePool}; @@ -39,7 +39,7 @@ if #[cfg(feature = "ssr")] { provide_context(auth_session.clone()); provide_context(app_state.pool.clone()); }, - || view! { } + TodoApp ); handler(req).await.into_response() } @@ -80,7 +80,7 @@ if #[cfg(feature = "ssr")] { let conf = get_configuration(None).await.unwrap(); let leptos_options = conf.leptos_options; let addr = leptos_options.site_addr; - let routes = generate_route_list(|| view! { }).await; + let routes = generate_route_list(TodoApp); let app_state = AppState{ leptos_options, diff --git a/examples/ssr_modes_axum/src/main.rs b/examples/ssr_modes_axum/src/main.rs index cfc94d8bf..641f76cdf 100644 --- a/examples/ssr_modes_axum/src/main.rs +++ b/examples/ssr_modes_axum/src/main.rs @@ -10,7 +10,7 @@ async fn main() { let addr = conf.leptos_options.site_addr; let leptos_options = conf.leptos_options; // Generate the list of routes in your Leptos App - let routes = generate_route_list(|| view! { }).await; + let routes = generate_route_list(App); // Explicit server function registration is no longer required // on the main branch. On 0.3.0 and earlier, uncomment the lines diff --git a/examples/todo_app_sqlite_axum/src/main.rs b/examples/todo_app_sqlite_axum/src/main.rs index 483b9f050..f4b74c827 100644 --- a/examples/todo_app_sqlite_axum/src/main.rs +++ b/examples/todo_app_sqlite_axum/src/main.rs @@ -48,7 +48,7 @@ cfg_if! { let conf = get_configuration(None).await.unwrap(); let leptos_options = conf.leptos_options; let addr = leptos_options.site_addr; - let routes = generate_route_list(|| view! { }).await; + let routes = generate_route_list(TodoApp); // build our application with a route let app = Router::new() diff --git a/examples/todo_app_sqlite_viz/src/main.rs b/examples/todo_app_sqlite_viz/src/main.rs index 6ae939b1c..f0f1bced1 100644 --- a/examples/todo_app_sqlite_viz/src/main.rs +++ b/examples/todo_app_sqlite_viz/src/main.rs @@ -24,7 +24,7 @@ cfg_if! { move || { provide_context(id.clone()); }, - || view! { }, + TodoApp, ); handler(req).await } @@ -51,7 +51,7 @@ cfg_if! { let conf = get_configuration(None).await.unwrap(); let leptos_options = conf.leptos_options; let addr = leptos_options.site_addr; - let routes = generate_route_list(|| view! { }).await; + let routes = generate_route_list(TodoApp); // build our application with a route let app = Router::new() @@ -60,7 +60,7 @@ cfg_if! { .leptos_routes( leptos_options.clone(), routes, - || view! { }, + TodoApp, ) .get("/*", file_and_error_handler) .with(State(leptos_options)); diff --git a/integrations/axum/src/lib.rs b/integrations/axum/src/lib.rs index d2e0893fd..76933fa06 100644 --- a/integrations/axum/src/lib.rs +++ b/integrations/axum/src/lib.rs @@ -1206,28 +1206,26 @@ where /// create routes in Axum's Router without having to use wildcard matching or fallbacks. Takes in your root app Element /// as an argument so it can walk you app tree. This version is tailored to generate Axum compatible paths. #[tracing::instrument(level = "trace", fields(error), skip_all)] -pub async fn generate_route_list( +pub fn generate_route_list( app_fn: impl Fn() -> IV + 'static + Clone, ) -> Vec where IV: IntoView + 'static, { - generate_route_list_with_exclusions_and_ssg(app_fn, None) - .await - .0 + generate_route_list_with_exclusions_and_ssg(app_fn, None).0 } /// Generates a list of all routes defined in Leptos's Router in your app. We can then use this to automatically /// create routes in Axum's Router without having to use wildcard matching or fallbacks. Takes in your root app Element /// as an argument so it can walk you app tree. This version is tailored to generate Axum compatible paths. #[tracing::instrument(level = "trace", fields(error), skip_all)] -pub async fn generate_route_list_with_ssg( +pub fn generate_route_list_with_ssg( app_fn: impl Fn() -> IV + 'static + Clone, ) -> (Vec, StaticDataMap) where IV: IntoView + 'static, { - generate_route_list_with_exclusions_and_ssg(app_fn, None).await + generate_route_list_with_exclusions_and_ssg(app_fn, None) } /// Generates a list of all routes defined in Leptos's Router in your app. We can then use this to automatically @@ -1235,16 +1233,14 @@ where /// as an argument so it can walk you app tree. This version is tailored to generate Axum compatible paths. Adding excluded_routes /// to this function will stop `.leptos_routes()` from generating a route for it, allowing a custom handler. These need to be in Axum path format #[tracing::instrument(level = "trace", fields(error), skip_all)] -pub async fn generate_route_list_with_exclusions( +pub fn generate_route_list_with_exclusions( app_fn: impl Fn() -> IV + 'static + Clone, excluded_routes: Option>, ) -> Vec where IV: IntoView + 'static, { - generate_route_list_with_exclusions_and_ssg(app_fn, excluded_routes) - .await - .0 + generate_route_list_with_exclusions_and_ssg(app_fn, excluded_routes).0 } /// Generates a list of all routes defined in Leptos's Router in your app. We can then use this to automatically @@ -1252,7 +1248,7 @@ where /// as an argument so it can walk you app tree. This version is tailored to generate Axum compatible paths. Adding excluded_routes /// to this function will stop `.leptos_routes()` from generating a route for it, allowing a custom handler. These need to be in Axum path format #[tracing::instrument(level = "trace", fields(error), skip_all)] -pub async fn generate_route_list_with_exclusions_and_ssg( +pub fn generate_route_list_with_exclusions_and_ssg( app_fn: impl Fn() -> IV + 'static + Clone, excluded_routes: Option>, ) -> (Vec, StaticDataMap) diff --git a/integrations/viz/src/lib.rs b/integrations/viz/src/lib.rs index f4eb90ca4..ac4491d67 100644 --- a/integrations/viz/src/lib.rs +++ b/integrations/viz/src/lib.rs @@ -988,47 +988,43 @@ where /// Generates a list of all routes defined in Leptos's Router in your app. We can then use this to automatically /// create routes in Viz's Router without having to use wildcard matching or fallbacks. Takes in your root app Element /// as an argument so it can walk you app tree. This version is tailored to generate Viz compatible paths. -pub async fn generate_route_list( +pub fn generate_route_list( app_fn: impl Fn() -> IV + 'static + Clone, ) -> Vec where IV: IntoView + 'static, { - generate_route_list_with_exclusions_and_ssg(app_fn, None) - .await - .0 + generate_route_list_with_exclusions_and_ssg(app_fn, None).0 } /// Generates a list of all routes defined in Leptos's Router in your app. We can then use this to automatically /// create routes in Viz's Router without having to use wildcard matching or fallbacks. Takes in your root app Element /// as an argument so it can walk you app tree. This version is tailored to generate Viz compatible paths. -pub async fn generate_route_list_with_ssg( +pub fn generate_route_list_with_ssg( app_fn: impl Fn() -> IV + 'static + Clone, ) -> (Vec, StaticDataMap) where IV: IntoView + 'static, { - generate_route_list_with_exclusions_and_ssg(app_fn, None).await + generate_route_list_with_exclusions_and_ssg(app_fn, None) } /// Generates a list of all routes defined in Leptos's Router in your app. We can then use this to automatically /// create routes in Viz's Router without having to use wildcard matching or fallbacks. Takes in your root app Element /// as an argument so it can walk you app tree. This version is tailored to generate Viz compatible paths. -pub async fn generate_route_list_with_exclusions( +pub fn generate_route_list_with_exclusions( app_fn: impl Fn() -> IV + 'static + Clone, excluded_routes: Option>, ) -> Vec where IV: IntoView + 'static, { - generate_route_list_with_exclusions_and_ssg(app_fn, excluded_routes) - .await - .0 + generate_route_list_with_exclusions_and_ssg(app_fn, excluded_routes).0 } /// Generates a list of all routes defined in Leptos's Router in your app. We can then use this to automatically /// create routes in Viz's Router without having to use wildcard matching or fallbacks. Takes in your root app Element /// as an argument so it can walk you app tree. This version is tailored to generate Viz compatible paths. -pub async fn generate_route_list_with_exclusions_and_ssg( +pub fn generate_route_list_with_exclusions_and_ssg( app_fn: impl Fn() -> IV + 'static + Clone, excluded_routes: Option>, ) -> (Vec, StaticDataMap)