Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Deprecate the path argument in the relevant LeptosRoutes trait methods. #1981

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all 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
6 changes: 2 additions & 4 deletions examples/counter_isomorphic/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ cfg_if! {
use actix_files::{Files};
use actix_web::*;
use crate::counters::*;
use leptos_actix::{generate_route_list, LeptosRoutes};
use leptos_actix::LeptosRoutes;

#[get("/api/events")]
async fn counter_events() -> impl Responder {
Expand Down Expand Up @@ -41,9 +41,7 @@ cfg_if! {
// Setting this to None means we'll be using cargo-leptos and its env vars.
// when not using cargo-leptos None must be replaced with Some("Cargo.toml")
let conf = get_configuration(None).await.unwrap();

let addr = conf.leptos_options.site_addr;
let routes = generate_route_list(|| view! { <Counters/> });

HttpServer::new(move || {
let leptos_options = &conf.leptos_options;
Expand All @@ -52,7 +50,7 @@ cfg_if! {
App::new()
.service(counter_events)
.route("/api/{tail:.*}", leptos_actix::handle_server_fns())
.leptos_routes(leptos_options.to_owned(), routes.to_owned(), || view! { <Counters/> })
.leptos_routes(leptos_options.to_owned(), Counters)
.service(Files::new("/", site_root))
//.wrap(middleware::Compress::default())
})
Expand Down
5 changes: 2 additions & 3 deletions examples/errors_axum/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ cfg_if! { if #[cfg(feature = "ssr")] {
};
use errors_axum::*;
use leptos::{logging::log, *};
use leptos_axum::{generate_route_list, LeptosRoutes};
use leptos_axum::LeptosRoutes;
}}

//Define a handler to test extractor with state
Expand Down Expand Up @@ -48,13 +48,12 @@ 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(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, App)
.leptos_routes(&leptos_options, App)
.fallback(file_and_error_handler)
.with_state(leptos_options);

Expand Down
10 changes: 4 additions & 6 deletions examples/hackernews/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@ use leptos::*;
cfg_if! {
// server-only stuff
if #[cfg(feature = "ssr")] {
use actix_files::{Files};
use actix_files::Files;
use actix_web::*;
use hackernews::{App};
use leptos_actix::{LeptosRoutes, generate_route_list};
use hackernews::App;
use leptos_actix::LeptosRoutes;

#[get("/style.css")]
async fn css() -> impl Responder {
Expand All @@ -25,8 +25,6 @@ cfg_if! {
let conf = get_configuration(None).await.unwrap();

let addr = conf.leptos_options.site_addr;
// Generate the list of routes in your Leptos App
let routes = generate_route_list(App);

HttpServer::new(move || {
let leptos_options = &conf.leptos_options;
Expand All @@ -36,7 +34,7 @@ cfg_if! {
.service(css)
.service(favicon)
.route("/api/{tail:.*}", leptos_actix::handle_server_fns())
.leptos_routes(leptos_options.to_owned(), routes.to_owned(), App)
.leptos_routes(leptos_options.to_owned(), App)
.service(Files::new("/", site_root))
//.wrap(middleware::Compress::default())
})
Expand Down
5 changes: 2 additions & 3 deletions examples/hackernews_axum/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ if #[cfg(feature = "ssr")] {
Router,
routing::get,
};
use leptos_axum::{generate_route_list, LeptosRoutes};
use leptos_axum::LeptosRoutes;
use hackernews_axum::fallback::file_and_error_handler;

#[tokio::main]
Expand All @@ -18,14 +18,13 @@ 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(App);

simple_logger::init_with_level(log::Level::Debug).expect("couldn't initialize logging");

// build our application with a route
let app = Router::new()
.route("/favicon.ico", get(file_and_error_handler))
.leptos_routes(&leptos_options, routes, || view! { <App/> } )
.leptos_routes(&leptos_options, App)
.fallback(file_and_error_handler)
.with_state(leptos_options);

Expand Down
5 changes: 2 additions & 3 deletions examples/hackernews_islands_axum/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ mod ssr_imports {
pub use axum::{routing::get, Router};
pub use hackernews_islands::fallback::file_and_error_handler;
pub use leptos::*;
pub use leptos_axum::{generate_route_list, LeptosRoutes};
pub use leptos_axum::LeptosRoutes;
}

#[cfg(feature = "ssr")]
Expand All @@ -15,12 +15,11 @@ async fn main() {
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(App);

// build our application with a route
let app = Router::new()
.route("/favicon.ico", get(file_and_error_handler))
.leptos_routes(&leptos_options, routes, App)
.leptos_routes(&leptos_options, App)
.fallback(file_and_error_handler)
.with_state(leptos_options);

Expand Down
5 changes: 2 additions & 3 deletions examples/hackernews_js_fetch/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ cfg_if! {
Router,
routing::post
};
use leptos_axum::{generate_route_list, LeptosRoutes};
use leptos_axum::LeptosRoutes;
use leptos::*;
use log::{info, Level};

Expand All @@ -59,11 +59,10 @@ cfg_if! {
console_error_panic_hook::set_once();

let leptos_options = LeptosOptions::builder().output_name("client").site_pkg_dir("pkg").build();
let routes = generate_route_list(App);

// build our application with a route
let app: axum::Router<(), axum::body::Body> = Router::new()
.leptos_routes(&leptos_options, routes, || view! { <App/> } )
.leptos_routes(&leptos_options, App)
.route("/api/*fn_name", post(leptos_axum::handle_server_fns))
.with_state(leptos_options);

Expand Down
18 changes: 9 additions & 9 deletions examples/session_auth_axum/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ if #[cfg(feature = "ssr")] {
use session_auth_axum::auth::*;
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_axum::{generate_route_list_with_ssg, LeptosRoutes, handle_server_fns_with_context};
use leptos::{logging::log, provide_context, get_configuration};
use sqlx::{SqlitePool, sqlite::SqlitePoolOptions};
use axum_session::{SessionConfig, SessionLayer, SessionStore};
Expand Down Expand Up @@ -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(TodoApp);
let routes = generate_route_list_with_sgg(TodoApp).0;

let app_state = AppState{
leptos_options,
Expand All @@ -90,13 +90,13 @@ if #[cfg(feature = "ssr")] {

// build our application with a route
let app = Router::new()
.route("/api/*fn_name", get(server_fn_handler).post(server_fn_handler))
.leptos_routes_with_handler(routes, get(leptos_routes_handler) )
.fallback(file_and_error_handler)
.layer(AuthSessionLayer::<User, i64, SessionSqlitePool, SqlitePool>::new(Some(pool.clone()))
.with_config(auth_config))
.layer(SessionLayer::new(session_store))
.with_state(app_state);
.route("/api/*fn_name", get(server_fn_handler).post(server_fn_handler))
.leptos_routes_with_handler(routes, get(leptos_routes_handler) )
.fallback(file_and_error_handler)
.layer(AuthSessionLayer::<User, i64, SessionSqlitePool, SqlitePool>::new(Some(pool.clone()))
.with_config(auth_config))
.layer(SessionLayer::new(session_store))
.with_state(app_state);

// run our app with hyper
// `axum::Server` is a re-export of `hyper::Server`
Expand Down
10 changes: 2 additions & 8 deletions examples/ssr_modes/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,11 @@ async fn main() -> std::io::Result<()> {
use actix_files::Files;
use actix_web::*;
use leptos::*;
use leptos_actix::{generate_route_list, LeptosRoutes};
use leptos_actix::LeptosRoutes;
use ssr_modes::app::*;

let conf = get_configuration(None).await.unwrap();
let addr = conf.leptos_options.site_addr;
// Generate the list of routes in your Leptos App
let routes = generate_route_list(|| view! { <App/> });

// Explicit server function registration is no longer required
// on the main branch. On 0.3.0 and earlier, uncomment the lines
Expand All @@ -24,11 +22,7 @@ async fn main() -> std::io::Result<()> {

App::new()
.route("/api/{tail:.*}", leptos_actix::handle_server_fns())
.leptos_routes(
leptos_options.to_owned(),
routes.to_owned(),
|| view! { <App/> },
)
.leptos_routes(leptos_options.to_owned(), App)
.service(Files::new("/", site_root))
//.wrap(middleware::Compress::default())
})
Expand Down
6 changes: 2 additions & 4 deletions examples/ssr_modes_axum/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,12 @@
async fn main() {
use axum::{routing::post, Router};
use leptos::{logging::log, *};
use leptos_axum::{generate_route_list, LeptosRoutes};
use leptos_axum::LeptosRoutes;
use ssr_modes_axum::{app::*, fallback::file_and_error_handler};

let conf = get_configuration(None).await.unwrap();
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(App);

// Explicit server function registration is no longer required
// on the main branch. On 0.3.0 and earlier, uncomment the lines
Expand All @@ -20,7 +18,7 @@ async fn main() {

let app = Router::new()
.route("/api/*fn_name", post(leptos_axum::handle_server_fns))
.leptos_routes(&leptos_options, routes, || view! { <App/> })
.leptos_routes(&leptos_options, App)
.fallback(file_and_error_handler)
.with_state(leptos_options);

Expand Down
10 changes: 2 additions & 8 deletions examples/suspense_tests/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,25 +4,19 @@ async fn main() -> std::io::Result<()> {
use actix_files::Files;
use actix_web::*;
use leptos::*;
use leptos_actix::{generate_route_list, LeptosRoutes};
use leptos_actix::LeptosRoutes;
use suspense_tests::app::*;

let conf = get_configuration(None).await.unwrap();
let addr = conf.leptos_options.site_addr;
// Generate the list of routes in your Leptos App
let routes = generate_route_list(|| view! { <App/> });

HttpServer::new(move || {
let leptos_options = &conf.leptos_options;
let site_root = &leptos_options.site_root;

App::new()
.route("/api/{tail:.*}", leptos_actix::handle_server_fns())
.leptos_routes(
leptos_options.to_owned(),
routes.to_owned(),
|| view! { <App/> },
)
.leptos_routes(leptos_options.to_owned(), App)
.service(Files::new("/", site_root))
//.wrap(middleware::Compress::default())
})
Expand Down
10 changes: 2 additions & 8 deletions examples/tailwind_actix/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ cfg_if! {
use actix_web::*;
use leptos::*;
use crate::app::*;
use leptos_actix::{generate_route_list, LeptosRoutes};
use leptos_actix::LeptosRoutes;

#[get("/style.css")]
async fn css() -> impl Responder {
Expand All @@ -16,22 +16,16 @@ cfg_if! {

#[actix_web::main]
async fn main() -> std::io::Result<()> {

// Setting this to None means we'll be using cargo-leptos and its env vars.
let conf = get_configuration(None).await.unwrap();

let addr = conf.leptos_options.site_addr;

// Generate the list of routes in your Leptos App
let routes = generate_route_list(|| view! { <App/> });

HttpServer::new(move || {
let leptos_options = &conf.leptos_options;
let site_root = &leptos_options.site_root;
let routes = &routes;
App::new()
.service(css)
.leptos_routes(leptos_options.to_owned(), routes.to_owned(), || view! { <App/> })
.leptos_routes(leptos_options.to_owned(), App)
.service(Files::new("/", site_root))
.wrap(middleware::Compress::default())
})
Expand Down
6 changes: 2 additions & 4 deletions examples/tailwind_axum/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
async fn main() {
use axum::{routing::post, Router};
use leptos::*;
use leptos_axum::{generate_route_list, LeptosRoutes};
use leptos_axum::LeptosRoutes;
use leptos_tailwind::{app::*, fallback::file_and_error_handler};
use log::info;

Expand All @@ -18,13 +18,11 @@ async fn main() {
let conf = get_configuration(None).await.unwrap();
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(App);

// build our application with a route
let app = Router::new()
.route("/api/*fn_name", post(leptos_axum::handle_server_fns))
.leptos_routes(&leptos_options, routes, || view! { <App/> })
.leptos_routes(&leptos_options, App)
.fallback(file_and_error_handler)
.with_state(leptos_options);

Expand Down
9 changes: 2 additions & 7 deletions examples/todo_app_sqlite/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ cfg_if! {
use actix_web::*;
use crate::todo::*;
use leptos::*;
use leptos_actix::{generate_route_list, LeptosRoutes};
use leptos_actix::LeptosRoutes;

#[get("/style.css")]
async fn css() -> impl Responder {
Expand All @@ -33,21 +33,16 @@ cfg_if! {

// Setting this to None means we'll be using cargo-leptos and its env vars.
let conf = get_configuration(None).await.unwrap();

let addr = conf.leptos_options.site_addr;

// Generate the list of routes in your Leptos App
let routes = generate_route_list(TodoApp);

HttpServer::new(move || {
let leptos_options = &conf.leptos_options;
let site_root = &leptos_options.site_root;
let routes = &routes;

App::new()
.service(css)
.route("/api/{tail:.*}", leptos_actix::handle_server_fns())
.leptos_routes(leptos_options.to_owned(), routes.to_owned(), TodoApp)
.leptos_routes(leptos_options.to_owned(), TodoApp)
.service(Files::new("/", site_root))
//.wrap(middleware::Compress::default())
})
Expand Down
5 changes: 2 additions & 3 deletions examples/todo_app_sqlite_axum/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ cfg_if! {
use crate::todo::*;
use todo_app_sqlite_axum::*;
use crate::fallback::file_and_error_handler;
use leptos_axum::{generate_route_list, LeptosRoutes};
use leptos_axum::LeptosRoutes;

//Define a handler to test extractor with state
async fn custom_handler(Path(id): Path<String>, State(options): State<LeptosOptions>, req: Request<AxumBody>) -> Response{
Expand Down Expand Up @@ -48,13 +48,12 @@ 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(TodoApp);

// 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! { <TodoApp/> } )
.leptos_routes(&leptos_options, TodoApp)
.fallback(file_and_error_handler)
.with_state(leptos_options);

Expand Down
Loading
Loading