RESTful Design: Paging Collections

后端 未结 3 803
遇见更好的自我
遇见更好的自我 2021-02-04 06:57

I am designing a REST api that needs paging (per x) enforces from the server side.

What would be the right way to page through any collection of resources:

Optio

3条回答
  •  盖世英雄少女心
    2021-02-04 07:41

    I'd go with option (2). Why?

    1. You can later add page-size parameter to the query so the client can specify the page size.
    2. In case no page parameter was specified you can just return the first page (the default). In many cases you client might need only the first page, so it simplifies the protocol between client and server.

提交回复
热议问题