AshTypescript.TypedController.Codegen.RouterIntrospector (ash_typescript v0.17.3)

Copy Markdown View Source

Introspects a Phoenix Router to match routes to generated controllers.

Uses Router.__routes__/0 to discover the actual URL paths for controller actions generated by the TypedController extension.

When a controller is mounted at multiple scopes, each mount produces a separate path helper function. The scopes must use as: options to provide unique Phoenix helper names for disambiguation.

Summary

Functions

Gets route information by matching router entries to DSL-configured routes.

Functions

introspect(router_module, routes_config)

Gets route information by matching router entries to DSL-configured routes.

Returns a list of matched route info maps. When a controller action is mounted at multiple paths, returns one entry per mount with a scope_prefix derived from the Phoenix helper name.

%{
  source_module: source_module,
  controller: controller_module,
  route: %Route{},
  path: "/admin/pages/:id",
  method: :get,
  path_params: [:id],
  scope_prefix: "admin"  # nil when single mount
}

Raises if a controller action is mounted at multiple paths but the scopes don't have unique as: options (making disambiguation impossible).