View Source Routex.Extension.AttrGetters (Phoenix Routes Extension Framework v0.3.0-alpha.4)

Creates helper functions to get the Routex.Attrs given a binary url or a list of path segments. This way the attributes for route can be lazily loaded.

Configuration

# file /lib/example_web/routex_backend.ex
defmodule ExampleWeb.RoutexBackend do
  use Routex.Backend,
  extensions: [
+   Routex.Extension.AttrGetters,
],

Routex.Attrs

Requires

  • none

Sets

  • none

Helpers

  • attrs(url :: binary) :: map()
  • attrs(segments :: list) :: map()

Example

iex> ExampleWeb.Router.RoutexHelpers.attrs("/europe/nl/producten/?foo=baz")
%{
  __branch__: [0, 9, 3],
  __origin__: "/products",
  backend: ExampleWeb.LocalizedRoutes,
  contact: "verkoop@example.nl",
  locale: "nl",
  branch_name: "The Netherlands",
  branch_helper: "europe_nl",
}