Opening up the router restrictions a bit #1557
Replies: 4 comments 3 replies
-
I vote for allowing this in Lucky as well. I don't see any immediate benefit in limiting the places a dynamic segment is valid. Perhaps, I'm biased coming from Rails. 😅 I happen to know (a friend of mine work there) that IKEA uses a URL naming scheme along the lines of I guess one could argue that the Lucky way of doing it would be treating it as a single slug, and then parse it from within the appropriate action. |
Beta Was this translation helpful? Give feedback.
-
My experience with building out the amber_router led me to a few lessons:
From an algorithms perspective, the simpler the better. This logic runs at the beginning of every request. It's not premature to say that some performance optimization here is important -- the amber router publishes performance comparisons for this reason. If you're |
Beta Was this translation helpful? Give feedback.
-
I’d have to dive into it more but I’m not against allowing more complex routes. My main concern is performance and maintainability of the router code. We were able to add globing and optional paths without performance issues and code was fairly clean. If we can do that for this then that is fine by me My personal opinion is that new apps can use a slash instead of a dash separator and it’d work just as well but as @robacarp mentioned this is largely preference. Also we have a anew style enforced that enforces underscores but it is optional and can be removed or replaced with your own that enforces dashes for example. Underscores we’re just the easiest to do and what I personally use hah. I’d love to have one built in for dashes though! |
Beta Was this translation helpful? Give feedback.
-
Ref: luckyframework/website#717 (comment)
In that thread, @kevinsjoberg and I were discussing the use of route path variables. Currently placing the variable anywhere isn't allowed (e.g.
/user-:user_id
is invalid). Lucky generally has pulled a lot from Elixir's Phoenix framework as well as Rails when deciding what and how to add things in, but Lucky has no goal to be 1-1 with any other framework. Our top goal first and foremost is catching bugs in development, and one of the ways we achieve this is by enforcing a stricter coding style. The idea here is that you're working on a team on some app, and different devs come in and out over the years. This can lead to people adding code in using their own styles which could potentially lead to inconsistencies or bugs.One recent feature was the route checks #1536 which ensures all routes use
_
underscores to separate words instead of the kebab case with dashes-
. (e.g./getting_started
is preferred over/getting-started
).With that said, Rails allows routes like
/user_:user_slug(.:format)
; should the Lucky Router be this flexible as well? My initial thought was "no", but then thinking about it, maybe it wouldn't be too bad to implement...Let me know your thoughts, and if you have ideas on how we can make it better. What things do you think the router should / should not do?
/cc. @paulcsmith
Beta Was this translation helpful? Give feedback.
All reactions