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

Conversation

gibbz00
Copy link
Contributor

@gibbz00 gibbz00 commented Nov 3, 2023

let app = Router::new()
    .leptos_routes(&leptos_options, generate_route_list(app), app)
// ...

becomes

let app = Router::new()
    .leptos_routes(&leptos_options, app)
// ...

Might be too much of a breaking change for such a subjective improvement. I'll refrain from sending in a PR updating start_axum until this change is deemed appropriate. 😊

@gbj gbj added this to the 0.6 milestone Nov 3, 2023
@gbj
Copy link
Collaborator

gbj commented Nov 3, 2023

I'm open to making a change this like in the future. As far as I can tell it would break ~100% of Leptos-Axum apps so of course it's not changeable until the next version. I am also not sure the churn of breaking everything is worth the benefit of saving 20 characters or so, but I'm open to being wrong.

@gibbz00
Copy link
Contributor Author

gibbz00 commented Nov 3, 2023

Spot on. Thought about mentioning that it could alternatively be added to the 0.6 milestone, but seems like you're way ahead of me :) Another option could also be to hold on until a major version is released that would require fixing ~100% of the packages regardless.

I'll make sure to fix the examples as well as the starter crate tomorrow for completeness’ sake.

gibbz00 added a commit to gibbz00/start-axum that referenced this pull request Nov 4, 2023
gibbz00 added a commit to gibbz00/start that referenced this pull request Nov 4, 2023
gibbz00 added a commit to gibbz00/start-axum-workspace that referenced this pull request Nov 4, 2023
@gibbz00 gibbz00 changed the title axum: Deprecate the path argument in the relevant LeptosRoutes trait methods. Deprecate the path argument in the relevant LeptosRoutes trait methods. Nov 4, 2023
@gibbz00
Copy link
Contributor Author

gibbz00 commented Nov 4, 2023

Hey again,

I went ahead to made the changes consistent in the viz and actix routers, as well as opening up fix PRs in the respective starter repos. More so to not keep an incomplete PR lying around, and not to as a means to push for it being merged right away. I would be fully understanding if you choose to close this whenever, given previous discussions ✌️

@benwis
Copy link
Contributor

benwis commented Nov 25, 2023

The reason to do this is to allow people to pass in some routes, but not all routes, for automatic route generation in LeptosRoutes. Moving it inside saves props, sure, but also removes the ability to handle them separately. I imagine we'll have to find a workaround before this can be merged

@gibbz00
Copy link
Contributor Author

gibbz00 commented Nov 26, 2023

Hi @benwis!

Could you give me an example for when/how it would be useful? You're probably on to something, it's more that I lack the experience to understand when that could be utilized 🙈

@benwis
Copy link
Contributor

benwis commented Nov 26, 2023 via email

@gibbz00
Copy link
Contributor Author

gibbz00 commented Nov 27, 2023

Ahh, well put.

leptos_routes_with_handler() still exists. Would it be possible to use it for that use case?

fn leptos_routes_with_handler<H, T>(
self,
paths: Vec<RouteListing>,
handler: H,
) -> Self
where
H: axum::handler::Handler<T, S, axum::body::Body>,
T: 'static;
}

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) )

@benwis
Copy link
Contributor

benwis commented Nov 27, 2023

It has a different usecase, it's meant mostly to let people provide their own context. Unfortunately, at least for the idea of middleware support, I don't think you could apply that. You'd have to do per handler middleware instead of layer middleware. Something to think about though

@benwis
Copy link
Contributor

benwis commented Jan 13, 2024

In the interest of maintaining flexibility and now with server fn routes being added to the macro, we'll need to preserve the path var. Thanks for making the PR and having the conversation!

@benwis benwis closed this Jan 13, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants