Getting a count of returns seen by a RESTful request

后端 未结 4 1144
温柔的废话
温柔的废话 2020-12-14 09:17

So, I\'d like to know how many results I\'ll be getting back from a RESTful uri GET request. I don\'t know of any way to do that at this point. Is there a way to do that?

4条回答
  •  情歌与酒
    2020-12-14 09:54

    You should be able to take care of this in your REST resource name design. You'd start with something like:

    • /widget/12345 (the representation of widget 12345)
    • /widgets (the list of all widget resource names, ie links)

    You might quickly decide that "/widgets" will be a humongous list and decide to support pages, something like

    • /widgets/page/43 (this could have links to the 4200th to 4299th widgets, and additional information like the total number of pages or a count of the widgets.)

    In other cases you can subdivide a large set into a natural hierarchy:

    • /widgets/mahogany, /widgets/oak, ...
    • /movies/drama, /movies/romance, ...
    • /computers/harddrives/seagate, /computers/usbdrives/kingston

    And you can define queries too:

    • /widgets?maxprice=200&maxweight=4

提交回复
热议问题