REST services and multiple representations of same object with different fields

后端 未结 4 1962

Let\'s say you have an Person object, with several fields like first_name, last_name, age which are relatively small, and

4条回答
  •  悲哀的现实
    2020-12-10 19:15

    Use query parameters.
    api/people?fields=first_name,last_name,age

    Using the ?fields= syntax is simple to read; a client can select just the information needed at a given time.

    On a somewhat-related note, HTTP also includes support for partial content requests, denoted by the 206 response code. You could potentially provide part of the life_story without returning all of it.

提交回复
热议问题