mirror of
https://github.com/ash-project/ash_json_api_wrapper.git
synced 2024-09-21 13:52:59 +12:00
a9d94bdd9b
improvement: new spark_function_behaviour for `before_request`
20 lines
532 B
Elixir
20 lines
532 B
Elixir
defmodule AshJsonApiWrapper.Paginator do
|
|
@moduledoc """
|
|
Behavior for scanning pages of a paginated endpoint.
|
|
"""
|
|
|
|
@type ref :: {module, Keyword.t()}
|
|
|
|
defmacro __using__(_) do
|
|
quote do
|
|
@behaviour AshJsonApiWrapper.Paginator
|
|
end
|
|
end
|
|
|
|
@callback continue(
|
|
response :: term,
|
|
entities :: [Ash.Resource.record()],
|
|
request :: Finch.Request.t(),
|
|
opts :: Keyword.t()
|
|
) :: {:ok, %{optional(:params) => map, optional(:headers) => map}} | :halt
|
|
end
|