Response Formatting

Response Formatting

When handling a RESTful API request, an application usually takes the following steps that are related with response formatting:

  1. Determine various factors that may affect the response format, such as media type, language, version, etc. This process is also known as content negotiation.
  2. Convert resource objects into arrays, as described in the Resources section. This is done by yii\rest\Serializer.
  3. Convert arrays into a string in the format as determined by the content negotiation step. This is done by 登录查看完整内容