Open kshychko opened 5 years ago
That's an interesting question, we actually use a standard "HTTP approach" based on https://tools.ietf.org/html/rfc7233#section-4.1 .
It actually aplies quite well to our purpose, as explained here : http://otac0n.com/blog/2012/11/21/range-header-i-choose-you.html
What do you think ?
Here is the perfect answer why we should not use range header: https://stackoverflow.com/questions/21765555/why-most-api-paginations-do-not-rely-on-http-range-header
Proxy servers and other middleware mess with it and the rfc allows for inconsistency to emerge:
I conform to the HTTP spec when I'm sending [a custom range unit] and they conform to HTTP when they ignore it WebDAV uses HTTP extensions correctly, IMO, but rarely works over the Internet for exactly this reason
there are example issues in the comments of the blogpost you linked
From RFC 7233:
A proxy MAY discard a Range header field that contains a range unit it does not understand.
Thank you @Fak3 for your feedback. This actually triggered an interesting debate back here :) I'll make a second proposition, please feel free to comment and propose an alternative.
First, I think there is no debate, we need to use an offset approach. (limit+ offset)
We need to decide where to put the pagination information in the request ==> I believe it makes more sense in the query : like /items?limit=20&offset=40
What do you think ?
I think the approach should be consistent across all API work from edi3 so maybe not just a code list issue, we should consider or re-pose the question and reference this ticket and useful comments in the #general slack channel, would you agree @rgenoulaz
What is also a problem is that the pagination scheme used is not part of the swagger schema. at least not the schema I have seen compared to the current hosted service.
There are different pagination schemas can be applied and we need to choose one a standard, so we use it for all APIs.
We could consider ones from Django rest framework - https://www.django-rest-framework.org/api-guide/pagination/#api-reference . The same strategies are mentioned in JSON API specification - https://jsonapi.org/format/#fetching-pagination
I would opt for offset strategy, but all of them are valid options.