-
-
Notifications
You must be signed in to change notification settings - Fork 695
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
Conversation
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. |
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. |
path
argument in the relevant LeptosRoutes
trait methods.path
argument in the relevant LeptosRoutes
trait methods.
Hey again, I went ahead to made the changes consistent in the |
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 |
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 🙈 |
Sure, let's say you wanted to apply an Axum middleware like TraceLayer, CompressionLayer, or some kind of auth thing, to specific routes in your app, kinda like so
```rust
let router = Router
.route("/compressme", get(handler))
.layer(CompressionLayer::new())
```
because LeptosRoutes will automatically find all routes in your Leptos app, and you can't have conflicting routes, you first have to exclude the route from general handling
```rust
let routes = generate_route_list_with_exclusions("/compressme")
// then pass the routes to LeptosRoutes via the path param
```
…On Sun, Nov 26, 2023, at 1:50 AM, Gabriel Hansson wrote:
Hi @benwis <https://github.com/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 🙈
—
Reply to this email directly, view it on GitHub <#1981 (comment)>, or unsubscribe <https://github.com/notifications/unsubscribe-auth/ABVBTCOCHSMOIRFTSKHQ3R3YGMGHLAVCNFSM6AAAAAA64RQZECVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTQMRWG4ZTQMBUGQ>.
You are receiving this because you were mentioned.Message ID: ***@***.***>
|
Ahh, well put.
leptos/integrations/axum/src/lib.rs Lines 1437 to 1445 in a8e25af
leptos/examples/session_auth_axum/src/main.rs Lines 91 to 93 in a8e25af
|
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 |
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! |
becomes
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. 😊