# `Backpex.Router`
[🔗](https://github.com/naymspace/backpex/blob/0.18.3/lib/backpex/router.ex#L2)

Provides LiveView routing for Backpex resources.

# `active?`

Checks whether the to path is the same as the current path

# `backpex_routes`
*macro* 

# `cookie_path`

Finds the cookie path by the given socket.

# `filter_actions`

Filters `actions` based on `only` and `except` parameters.

## Examples

    iex> Backpex.Router.filter_actions([:index, :edit, :show], [:index], nil)
    [:index]
    iex> Backpex.Router.filter_actions([:index, :edit, :show], nil, [:index])
    [:edit, :show]
    iex> Backpex.Router.filter_actions([:index, :edit, :show], nil, nil)
    [:index, :edit, :show]
    iex> Backpex.Router.filter_actions([:index, :edit, :show], [], [])
    [:index, :edit, :show]

# `get_path`

Finds the raw path by the given socket and module and puts the path params into the raw path.

# `get_path`

# `has_resource_actions?`

# `live_resources`
*macro* 

Defines "RESTful" routes for a Backpex resource.

## Options

* `:only` - Only generate routes for these actions, e.g. `[:index, :show]` The default value is `nil`.

* `:except` - Generate routes for all actions except these, e.g. `[:edit]` The default value is `nil`.

* `:container` (`t:term/0`) - An optional tuple for the HTML tag and DOM attributes for the LiveView container The default value is `nil`.

* `:as` - Optionally configures the named helper The default value is `nil`.

* `:metadata` - A map to optional feed metadata used on telemetry events and route info The default value is `nil`.

* `:private` - An optional map of private data to put in the plug connection The default value is `nil`.

## Example

    defmodule MyAppWeb.Router
      import Backpex.Router

      scope "/admin", MyAppWeb do
        pipe_through :browser

        live_session :default, on_mount: Backpex.InitAssigns do
          live_resources("/users", UserLive, only: [:index])
          live_resources("/users", UserLive, only: [:index], metadata: %{route_name: :foo, access: :user}
        end
      end
    end

# `member?`

Checks whether `item` is member of `list` and returns `default` value if list is `nil` or empty.

## Examples

    iex> Backpex.Router.member?([:index], :index, true)
    true
    iex> Backpex.Router.member?([:edit], :index, true)
    false
    iex> Backpex.Router.member?([], :index, true)
    true
    iex> Backpex.Router.member?(nil, :index, true)
    true

# `put_route_params`

Replace path params with actual params

## Examples

    iex> Backpex.Router.put_route_params("/:param1/events/:param2/show", %{"param1" => "123", "param2" => "xyz", "test" => "abcdef"})
    "/123/events/xyz/show"
    iex> Backpex.Router.put_route_params("/:param1/events/:id/edit", %{"param1" => "123", "id" => "xyz"})
    "/123/events/xyz/edit"
    iex> Backpex.Router.put_route_params("/:param1/events/:id/edit", %{"param1" => "123", "id" => "hällö / world"})
    "/123/events/h%C3%A4ll%C3%B6+%2F+world/edit"
    iex> Backpex.Router.put_route_params("/events", %{"param1" => "123", "param2" => "xyz"})
    "/events"
    iex> Backpex.Router.put_route_params("/events", %{})
    "/events"
    iex> Backpex.Router.put_route_params("/:id/users", %{})
    ** (ArgumentError) Cannot build route '/:id/users' because required parameter 'id' is missing in the list of params.

---

*Consult [api-reference.md](api-reference.md) for complete listing*
