This PR is an attempt to support GitHub's pagination API.
At present, this package allows you to construct a request with FetchCount, which has constructors FetchAtLeast Word and FetchAll. Both of these cause the library to repeatedly call the GitHub endpoint as many times as necessary to collect the desired number of items.
This obscures the actual pagination API from the user. What if I want to fetch a specific page? And what if I want to access the Link header information returned by the GitHub API, to determine the total number of pages, next/last page links, etc.?
This PR adds a new constructor to FetchCount called FetchPage PageParams. PageParams allows you to specify the page and/or perPage as integers, and you will get exactly the items you're asking for.
This PR also exposes a function parsePageLinks, which you can use to extract the page links from an HTTP response. You can use it like this:
mgr <- newManager tlsManagerSettings
ret <- executeRequestWithMgrAndRes mgr auth $
issuesForRepoR owner repo mempty (GitHub.FetchPage (GitHub.PageParams (Just 2) (Just 1)))
case ret of
Left e -> expectationFailure . show $ e
Right res -> do
let issues = responseBody res
let pageLinks = GitHub.parsePageLinks res
putStrLn ("pageLinks: " ++ show pageLinks)
I'd like to expose this in a nicer way at the higher levels of the API, like the github function. Maybe by providing a githubPaged version that returns the response value and also a PageLinks object. But this is serviceable enough for now. More API design suggestions are welcome!
This PR is an attempt to support GitHub's pagination API.
At present, this package allows you to construct a request with
FetchCount
, which has constructorsFetchAtLeast Word
andFetchAll
. Both of these cause the library to repeatedly call the GitHub endpoint as many times as necessary to collect the desired number of items.This obscures the actual pagination API from the user. What if I want to fetch a specific page? And what if I want to access the
Link
header information returned by the GitHub API, to determine the total number of pages, next/last page links, etc.?This PR adds a new constructor to
FetchCount
calledFetchPage PageParams
.PageParams
allows you to specify thepage
and/orperPage
as integers, and you will get exactly the items you're asking for.This PR also exposes a function
parsePageLinks
, which you can use to extract the page links from an HTTP response. You can use it like this:I'd like to expose this in a nicer way at the higher levels of the API, like the
github
function. Maybe by providing agithubPaged
version that returns the response value and also aPageLinks
object. But this is serviceable enough for now. More API design suggestions are welcome!