Paging in a Rest Collection

前端 未结 12 1824
走了就别回头了
走了就别回头了 2020-12-02 03:37

I\'m interested in exposing a direct REST interface to collections of JSON documents (think CouchDB or Persevere). The problem I\'m running into is how to handle the G

12条回答
  •  攒了一身酷
    2020-12-02 04:33

    You can still return Accept-Ranges and Content-Ranges with a 200 response code. These two response headers give you enough information to infer the same information that a 206 response code provides explicitly.

    I would use Range for pagination, and have it simply return a 200 for a plain GET.

    This feels 100% RESTful and doesn't make browsing any more difficult.

    Edit: I wrote a blog post about this: http://otac0n.com/blog/2012/11/21/range-header-i-choose-you.html

提交回复
热议问题