View Source JSONAPIPlug.Pagination behaviour (jsonapi_plug v2.0.0)
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
Callbacks
@callback paginate( [JSONAPIPlug.Resource.t()] | nil, Plug.Conn.t() | nil, params(), JSONAPIPlug.Resource.options() ) :: links()
Functions
@spec url_for( [JSONAPIPlug.Resource.t()], Plug.Conn.t() | nil, params() | nil ) :: JSONAPIPlug.Document.LinkObject.t()