# `PhoenixMountable.Definition`
[🔗](https://github.com/hattoriai/phoenix_mountable/blob/v0.2.1/lib/phoenix_mountable/definition.ex#L2)

The macros of a definition module: `options/1`, `routes/1` and `pipeline/2`.

They are imported by `use PhoenixMountable`.

## Options

`options/1` declares the options of the mount macro, as a
[NimbleOptions](https://hexdocs.pm/nimble_options) schema. They are
validated when the host router compiles, and documented in the mount
macro's docs.

    options resolver: [
              type: :atom,
              default: MyLib.Resolver,
              verify: {:behaviour, MyLib.Resolver},
              doc: "The module that resolves the current user."
            ],
            features: [type: {:list, :atom}, default: []]

Besides the NimbleOptions keys, an option can have `:verify`:
`:module` checks that the value names an existing module, and
`{:behaviour, mod}` also checks that it implements `mod` (or is `mod`).
The check runs after the host router compiles: a module that uses the
host's verified routes depends on the router, so checking it while the
router compiles would deadlock.

The values are in `mount.options`, a map with every declared option.

## Routes

`routes/1` declares the library's routes with the macros of
`PhoenixMountable.Routes`, relative to the mount path:

    routes do
      get "/export", MyLib.ExportController, :csv

      live_session :default, on_mount: [MyLib.Auth] do
        live "/", MyLib.HomeLive, :index
      end
    end

## Pipelines

`pipeline/2` defines a pipeline of the library, like `Phoenix.Router.pipeline/2`,
for its routes to `pipe_through`. It is compiled into a module plug, so the
host needs nothing in its own router.

    pipeline :api do
      plug :accepts, ["json"]
    end

# `options`
*macro* 

Declares the options of the mount macro. See the module documentation.

# `pipeline`
*macro* 

Defines a pipeline of the library. See the module documentation.

# `routes`
*macro* 

Declares the routes of the library. See `PhoenixMountable.Routes`.

---

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