Nex.RouteDiscovery
(nex_core v0.4.3)
Copy Markdown
Discovers and matches dynamic routes from file system structure.
Supports:
[param]- Single dynamic parameter (e.g.,users/[id].exmatches/users/123)[...param]- Catch-all parameter (e.g.,docs/[...path].exmatches/docs/a/b/c)- Mixed routes (e.g.,
files/[category]/[...path].ex) - Nested dynamic routes (e.g.,
users/[id]/profile.ex)
Summary
Functions
Clears the route cache. Called when files change during development.
Discovers all routes from the given source directory. Returns a list of route definitions.
Gets or initializes the route cache for an application. Routes are cached in ETS for performance.
Matches a URL path against discovered routes. Returns {:ok, module_name, params} or :error
Unified route resolution entry point.
Functions
Clears the route cache. Called when files change during development.
Discovers all routes from the given source directory. Returns a list of route definitions.
Gets or initializes the route cache for an application. Routes are cached in ETS for performance.
Matches a URL path against discovered routes. Returns {:ok, module_name, params} or :error
Unified route resolution entry point.
Examples
resolve(:pages, ["users", "123"])
# => {:ok, MyApp.Pages.Users.Id, %{"id" => "123"}}
resolve(:api, ["users"])
# => {:ok, MyApp.Api.Users, %{}}
resolve(:action, ["todos", "create_todo"])
# => {:ok, MyApp.Pages.Todos, "create_todo", %{}}