View Source JSONAPIPlug.Pagination behaviour (jsonapi_plug v1.0.5)

JSON:API Pagination strategy

https://jsonapi.org/format/#fetching-pagination

Pagination links can be generated by implementing a module conforming to the JSONAPIPlug.Pagination behavior and configuring the pagination of your API module:

defmodule MyApp.MyController do
  plug JSONAPIPlug.Plug, api: MyApp.MyApi, resource: MyApp.MyResource
end
config :my_app, MyApp.API, pagination: MyApp.MyPagination

Actual pagination needs to be handled by your application and is outside the scope of this library.

Links can be generated using the JSONAPIPlug.page information stored in the connection jsonapi_plug private field and by passing additional information to your pagination module by passing options from your controller.

See the tests for an example implementation of page based pagination strategy.

Summary

Types

@type link() :: :first | :last | :next | :prev
@type links() :: %{required(link()) => String.t()}
@type options() :: Keyword.t()
@type params() :: %{required(String.t()) => String.t()}
@type t() :: module()

Callbacks

Link to this callback

paginate(t, list, arg3, params, options)

View Source

Functions