fazland / api-platform-bundle

MIT License
4 stars 1 forks source link

Pagination: use HTTP headers #11

Open alekitto opened 4 years ago

alekitto commented 4 years ago

HTTP headers could be used for pagination (and ordering) in a more RESTful way.

Standard Accept-Ranges and Range HTTP header could be used to paginate lists. My proposal is to adopt two custom units for ranges:

A custom X-Order header could be introduced to set the list order, allowing an order field to be freely filtered without name collisions. In this case the header should have the following format:

  X-Order: token; ASC | DESC
massimilianobraglia commented 4 years ago

Indeed, HTTP headers could be used. Can you point out the Accept-Ranges and Range in the standard? Agree also for the X-Order header. Much better probably than specify an OrderColumn that overrides the order name (or using another one)

alekitto commented 4 years ago

Range: https://tools.ietf.org/html/rfc7233#section-3.1 (here's the MDN article: https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Range)

Accept-Ranges: https://tools.ietf.org/html/rfc7233#section-2.3 (MDN: https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Accept-Ranges)

As you can see in the IANA HTTP Range Unit Registry only bytes and none are registered units. All others range specification are usable.