# `Aludel.Web.Resolver`
[🔗](https://github.com/ccarvalho-eng/aludel/blob/main/lib/aludel/web/resolver.ex#L1)

Behavior for customizing dashboard access and user identification.

Host applications can implement this behavior to control who can access
the dashboard, identify users, and customize refresh rates.

## Example

    defmodule MyApp.AludelResolver do
      @behaviour Aludel.Web.Resolver

      @impl true
      def resolve_user(conn) do
        conn.assigns[:current_user]
      end

      @impl true
      def resolve_access(user) do
        if user && user.role == :admin, do: :all, else: :read_only
      end

      @impl true
      def resolve_refresh(_user) do
        15
      end
    end

Then configure it in your router:

    use Aludel.Web, :router,
      resolver: MyApp.AludelResolver

## Default Behavior

If no custom resolver is configured, the defaults are:
- `resolve_user/1` returns `nil`
- `resolve_access/1` returns `:all`
- `resolve_refresh/1` returns `5`

# `resolve_access`

```elixir
@callback resolve_access(user :: term()) :: :all | :read_only
```

Resolves the access level for a user.

Return `:all` for full access or `:read_only` for restricted access.

# `resolve_refresh`

```elixir
@callback resolve_refresh(user :: term()) :: pos_integer()
```

Resolves the refresh interval in seconds for a user.

# `resolve_user`

```elixir
@callback resolve_user(conn :: Plug.Conn.t()) :: term()
```

Resolves the current user from the connection.

Return `nil` if no user is authenticated.

# `call_with_fallback`

```elixir
@spec call_with_fallback(module(), atom(), list()) :: term()
```

Calls a resolver callback with fallback to default implementation.

If the resolver module implements the callback, it is called with the
given args. Otherwise, the default implementation is used.

---

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