Using Route classes instead of hash_branches #305
Replies: 2 comments 1 reply
-
Using separate Roda applications for routing branches is fine. It's slightly slower than the For this approach, you could consider using the Note that if you want code reloading for an application that uses hash_branches, you can use rack-unreloader for the autoloading/reloading part. That's the approach I use in my production applications, and how roda-sequel-stack is setup (https://github.com/jeremyevans/roda-sequel-stack). But I can understand wanting to use Zeitwerk instead, and the |
Beta Was this translation helpful? Give feedback.
-
I know this may be a little late. But i was working on this last night. I followed ur example with hash-branches and sure enough Zeitwerk complained. What i have done so far is to follow the project structure, but have Zeitwerk exclude the routes directory. I use the autoload_hash_branches plugin to load the routes directory. Seems to work fine. I have not tried Zeitwerk reloading yet since i have such a small prototype app right now and its just as easy to restart. I'll be trying the autoload in a week or so. |
Beta Was this translation helpful? Give feedback.
-
Hey there,
I was working on setting up my web framework using Roda, Zeitwerk, and Dry-System.
I was running into a lot of issues getting around code reloading and have been problem-solving this for a couple of weeks at this point when in conversation with another member of the community, we'd discussed mounting what was hash_branches as their own Roda applications. This worked! Zeitwerk is happy, and I haven't encountered any problems when I manually climb them.
That being said, there is probably a performance hit by mounting the apps like that compared to hash_branches. Still, I've been pulling my hair out on this code-loading issue for long enough that I am okay with it until a spark of inspiration or some help can come my way.
The discussion question: Are there drawbacks to mounting and running individual Roda apps for each branched route?
Some more details below highlight the directory structure and how I am metaprogramming the apps and mounting them.
The directory structure is not the traditional "MVC" or bucket system. It is based on allocating resources and the locality of behavior. It looks like such:
With some metaprogramming and directory conventions, there could be a route that loads all the subpath applications themselves. There might be some edge cases on constating; if you have any thoughts, feel free to let me know.
Beta Was this translation helpful? Give feedback.
All reactions