Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

added 2 more fields to help with pagination as well as normalized key… #4

Merged
merged 1 commit into from
Sep 20, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions lib/scrivener/headers.ex
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@ defmodule Scrivener.Headers do
|> put_resp_header("link", build_link_header(uri, page))
|> put_resp_header("total", Integer.to_string(page.total_entries))
|> put_resp_header("per-page", Integer.to_string(page.page_size))
|> put_resp_header("total-pages", Integer.to_string(page.total_pages))
Copy link
Member

@doomspork doomspork Sep 16, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is the point of changing the header keys? It introduces a breaking change with previous versions and the gain is unclear.

|> put_resp_header("page-number", Integer.to_string(page.page_number))
end

@spec build_link_header(URI.t, Scrivener.Page.t) :: String.t
Expand Down
2 changes: 2 additions & 0 deletions test/scrivener/headers_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ defmodule Scrivener.HeadersTests do

assert headers["total"] == "50"
assert headers["per-page"] == "10"
assert headers["total-pages"] == "5"
assert headers["page-number"] == "3"
links = String.split(headers["link"], ", ")
assert ~s(<http://www.example.com/test?foo=bar&page=1>; rel="first") in links
assert ~s(<http://www.example.com/test?foo=bar&page=5>; rel="last") in links
Expand Down