{"id":13508177,"url":"https://github.com/beam-community/scrivener_headers","last_synced_at":"2025-12-11T23:44:54.642Z","repository":{"id":42739840,"uuid":"53511906","full_name":"beam-community/scrivener_headers","owner":"beam-community","description":"Scrivener pagination with headers and web linking","archived":false,"fork":false,"pushed_at":"2025-06-25T18:57:58.000Z","size":58,"stargazers_count":52,"open_issues_count":0,"forks_count":9,"subscribers_count":14,"default_branch":"main","last_synced_at":"2025-06-25T19:37:57.507Z","etag":null,"topics":["elixir-lang","hex","http-headers","pagination","pagination-headers","scrivener"],"latest_commit_sha":null,"homepage":null,"language":"Elixir","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/beam-community.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":".github/CODEOWNERS","security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2016-03-09T16:10:39.000Z","updated_at":"2025-06-25T18:58:00.000Z","dependencies_parsed_at":"2024-09-08T14:05:27.745Z","dependency_job_id":"7d204946-9661-4235-baeb-92064c8157c5","html_url":"https://github.com/beam-community/scrivener_headers","commit_stats":{"total_commits":34,"total_committers":9,"mean_commits":"3.7777777777777777","dds":0.3529411764705882,"last_synced_commit":"f99a2f26310ec6d6f58c840c5d24823b35769724"},"previous_names":["doomspork/scrivener_headers"],"tags_count":7,"template":false,"template_full_name":null,"purl":"pkg:github/beam-community/scrivener_headers","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/beam-community%2Fscrivener_headers","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/beam-community%2Fscrivener_headers/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/beam-community%2Fscrivener_headers/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/beam-community%2Fscrivener_headers/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/beam-community","download_url":"https://codeload.github.com/beam-community/scrivener_headers/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/beam-community%2Fscrivener_headers/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":263089400,"owners_count":23412302,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["elixir-lang","hex","http-headers","pagination","pagination-headers","scrivener"],"created_at":"2024-08-01T02:00:49.305Z","updated_at":"2025-12-11T23:44:54.636Z","avatar_url":"https://github.com/beam-community.png","language":"Elixir","funding_links":[],"categories":["Framework Components"],"sub_categories":[],"readme":"# Scrivener.Headers\n\n[![Continuous Integration](https://github.com/beam-community/scrivener_headers/actions/workflows/ci.yaml/badge.svg)](https://github.com/beam-community/scrivener_headers/actions/workflows/ci.yaml)\n[![Module Version](https://img.shields.io/hexpm/v/scrivener_headers.svg)](https://hex.pm/packages/scrivener_headers)\n[![Hex Docs](https://img.shields.io/badge/hex-docs-lightgreen.svg)](https://hexdocs.pm/scrivener_headers/)\n[![Total Download](https://img.shields.io/hexpm/dt/scrivener_headers.svg)](https://hex.pm/packages/scrivener_headers)\n[![License](https://img.shields.io/hexpm/l/scrivener_headers.svg)](https://github.com/beam-community/scrivener_headers/blob/master/LICENSE.md)\n[![Last Updated](https://img.shields.io/github/last-commit/beam-community/scrivener_headers.svg)](https://github.com/beam-community/scrivener_headers/commits/master)\n\nHelpers for paginating API responses with [Scrivener](https://github.com/drewolson/scrivener) and HTTP headers.  Implements [RFC-5988](https://tools.ietf.org/html/rfc5988), the proposed standard for Web linking.\n\n## Setup\n\nAdd `:scrivener_headers` to `mix.exs`:\n\n```elixir\ndefp deps do\n  [\n    # ...\n    {:scrivener_headers, \"~\u003e 3.2\"}\n    # ...\n  ]\nend\n```\n\n## Usage\n\nWith `Scrivener.Headers.paginate/2` we can easily set our pagination headers:\n\n```elixir\ndef index(conn, params) do\n  page = MyApp.Person\n         |\u003e where([p], p.age \u003e 30)\n         |\u003e order_by([p], desc: p.age)\n         |\u003e preload(:friends)\n         |\u003e MyApp.Repo.paginate(params)\n\n  conn\n  |\u003e Scrivener.Headers.paginate(page)\n  |\u003e render(\"index.json\", people: page.entries)\nend\n```\n\nWith `curl --include` we can see our new headers:\n\n```shell\n$ curl --include 'https://localhost:4000/people?page=5'\nHTTP/1.1 200 OK\nLink: \u003chttp://localhost:4000/people?page=1\u003e; rel=\"first\",\n  \u003chttp://localhost:4000/people?page=30\u003e; rel=\"last\",\n  \u003chttp://localhost:4000/people?page=6\u003e; rel=\"next\",\n  \u003chttp://localhost:4000/people?page=4\u003e; rel=\"prev\"\nTotal: 300\nPer-Page: 10\n```\n\n### Using Custom Header Names\n\nOverride any number of pagination header names by passing opts with a `:header_keys` keyword list like so:\n\n```elixir\nScreenever.Headers.paginate(page,\n  header_keys: [\n    total: \"total\",\n    link: \"link\",\n    per_page: \"per-page\",\n    total_pages: \"total-pages\",\n    page_number: \"page-number\"\n  ]\n)\n```\n\n## Contributing\n\nContributions of all types are welcomed and encouraged.  Please\nmake appropriate use of [Issues][issues] and [Pull Requests][pulls].  All code\nshould have test coverage.\n\n[issues]: https://github.com/beam-community/scrivener_headers/issues\n[pulls]: https://github.com/beam-community/scrivener_headers/pulls\n\n\n## Copyright and License\n\nCopyright (c) 2016 Sean Callan\n\nReleased under the [MIT License](./LICENSE.md).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbeam-community%2Fscrivener_headers","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbeam-community%2Fscrivener_headers","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbeam-community%2Fscrivener_headers/lists"}