Scrivener.Headers (scrivener_headers v3.2.2) View Source

Helpers for paginating API responses with Scrivener and HTTP headers. Implements RFC-5988, the proposed standard for Web linking.

Use paginate/2 to set the pagination headers:

def index(conn, params) do
  page = MyApp.Person
         |> where([p], p.age > 30)
         |> order_by([p], desc: p.age)
         |> preload(:friends)
         |> MyApp.Repo.paginate(params)

  |> Scrivener.Headers.paginate(page)
  |> render("index.json", people: page.entries)

Link to this section Summary

Link to this section Functions

Link to this function

paginate(conn, page, opts \\ [])

View Source


paginate(Plug.Conn.t(), Scrivener.Page.t(), opts :: keyword()) :: Plug.Conn.t()

Add HTTP headers for a Scrivener.Page.