View Source NavEx.Adapter behaviour (NavEx v0.1.0)

Behaviour of the NavEx adapter saving the navigation history data.

Link to this section Summary

Callbacks

Lists children of the adapter to be started with the application. For example ETS table if your adapter needs it.

Inserts the path into user's navigation history. Takes %Plug.Conn{} as an argument, based on that fetches or creates user's identity (for example as an ID in cookies) and saves his path into the storage.

Returns user's last path. In case if user is not found or has no last path returns error tuple.

Lists user navigation history. In case if user is not found returns {:error, :not_found} tuple.

Returns user's Nth last path. In case if user is not found returns an error tuple. In case if number exceeds the navigation history limit returns an error tuple. In case if number exceed the user's navigation history records number returns an error tuple.

Link to this section Callbacks

@callback children() :: list()

Lists children of the adapter to be started with the application. For example ETS table if your adapter needs it.

@callback insert(%Plug.Conn{
  adapter: term(),
  assigns: term(),
  body_params: term(),
  cookies: term(),
  halted: term(),
  host: term(),
  method: term(),
  owner: term(),
  params: term(),
  path_info: term(),
  path_params: term(),
  port: term(),
  private: term(),
  query_params: term(),
  query_string: term(),
  remote_ip: term(),
  req_cookies: term(),
  req_headers: term(),
  request_path: term(),
  resp_body: term(),
  resp_cookies: term(),
  resp_headers: term(),
  scheme: term(),
  script_name: term(),
  secret_key_base: term(),
  state: term(),
  status: term()
}) ::
  {:ok,
   %Plug.Conn{
     adapter: term(),
     assigns: term(),
     body_params: term(),
     cookies: term(),
     halted: term(),
     host: term(),
     method: term(),
     owner: term(),
     params: term(),
     path_info: term(),
     path_params: term(),
     port: term(),
     private: term(),
     query_params: term(),
     query_string: term(),
     remote_ip: term(),
     req_cookies: term(),
     req_headers: term(),
     request_path: term(),
     resp_body: term(),
     resp_cookies: term(),
     resp_headers: term(),
     scheme: term(),
     script_name: term(),
     secret_key_base: term(),
     state: term(),
     status: term()
   }}

Inserts the path into user's navigation history. Takes %Plug.Conn{} as an argument, based on that fetches or creates user's identity (for example as an ID in cookies) and saves his path into the storage.

@callback last_path(%Plug.Conn{
  adapter: term(),
  assigns: term(),
  body_params: term(),
  cookies: term(),
  halted: term(),
  host: term(),
  method: term(),
  owner: term(),
  params: term(),
  path_info: term(),
  path_params: term(),
  port: term(),
  private: term(),
  query_params: term(),
  query_string: term(),
  remote_ip: term(),
  req_cookies: term(),
  req_headers: term(),
  request_path: term(),
  resp_body: term(),
  resp_cookies: term(),
  resp_headers: term(),
  scheme: term(),
  script_name: term(),
  secret_key_base: term(),
  state: term(),
  status: term()
}) :: {:ok, String.t()} | {:error, atom()}

Returns user's last path. In case if user is not found or has no last path returns error tuple.

@callback list(%Plug.Conn{
  adapter: term(),
  assigns: term(),
  body_params: term(),
  cookies: term(),
  halted: term(),
  host: term(),
  method: term(),
  owner: term(),
  params: term(),
  path_info: term(),
  path_params: term(),
  port: term(),
  private: term(),
  query_params: term(),
  query_string: term(),
  remote_ip: term(),
  req_cookies: term(),
  req_headers: term(),
  request_path: term(),
  resp_body: term(),
  resp_cookies: term(),
  resp_headers: term(),
  scheme: term(),
  script_name: term(),
  secret_key_base: term(),
  state: term(),
  status: term()
}) :: {:ok, list()} | {:error, :not_found}

Lists user navigation history. In case if user is not found returns {:error, :not_found} tuple.

Link to this callback

path_at(%Plug.Conn{}, number)

View Source
@callback path_at(
  %Plug.Conn{
    adapter: term(),
    assigns: term(),
    body_params: term(),
    cookies: term(),
    halted: term(),
    host: term(),
    method: term(),
    owner: term(),
    params: term(),
    path_info: term(),
    path_params: term(),
    port: term(),
    private: term(),
    query_params: term(),
    query_string: term(),
    remote_ip: term(),
    req_cookies: term(),
    req_headers: term(),
    request_path: term(),
    resp_body: term(),
    resp_cookies: term(),
    resp_headers: term(),
    scheme: term(),
    script_name: term(),
    secret_key_base: term(),
    state: term(),
    status: term()
  },
  number()
) :: {:ok, String.t()} | {:error, atom()}

Returns user's Nth last path. In case if user is not found returns an error tuple. In case if number exceeds the navigation history limit returns an error tuple. In case if number exceed the user's navigation history records number returns an error tuple.