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

Second iteration: add support for dynamic routes #3

Open
essenciary opened this issue Oct 7, 2024 · 0 comments
Open

Second iteration: add support for dynamic routes #3

essenciary opened this issue Oct 7, 2024 · 0 comments
Assignees

Comments

@essenciary
Copy link
Member

essenciary commented Oct 7, 2024

This is a bit more complex, for routes of form /a/:param/b where :param is dynamically passed and multiple URLs are generated for the single route.

The :param argument should be a iterable or a function and GenieBuilder.build should generate all the different pages for the route, corresponding to all the elements.

Architectural questions:

1/ can we handle one param and multiple params at once? That would be ideal. Maybe if we define some sort of interface and only use functions which must return a NamedTuple of :params at each iteration.
Such routes look like: /a/:param1/b/:param2
-> the challenge here is the combinations of param1 and 2 - ex if we have users and orders, we'd have users from id A to id Z, and for each user we'd have orders from id A to id Z.

2/ how do we define these rules? We could use a static.jl file where for each route we define the iterator -- but this would duplicate the routes definitions. I think the best would be for GenieBuilder to specialize Genie.Router.route to accept an extra argument, a lambda for the iterator rule.

So basically the routes.jl file would look like this:

using GenieStatic

route(...; ...existing_kw_args..., static_iterator=() -> ...)

This iterator lambda could use for example a database result.

@KwatMDPhD KwatMDPhD self-assigned this Oct 7, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: No status
Development

No branches or pull requests

2 participants