Skip to content

Commit

Permalink
docs: update user guide
Browse files Browse the repository at this point in the history
  • Loading branch information
kenjis committed Jan 31, 2024
1 parent 061c605 commit a286a7d
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions user_guide_src/source/outgoing/api_responses.rst
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,17 @@ Handling Response Types
When you pass your data in any of these methods, they will determine the data type to format the results as based on
the following criteria:

* If data is a string, it will be treated as HTML to send back to the client.
* If data is an array, it will be formatted according to the controller's ``$this->format`` value. If that is empty,
it will try to negotiate the content type with what the client asked for, defaulting to JSON
if nothing else has been specified within **Config/Format.php**, the ``$supportedResponseFormats`` property.
* The format is determined according to the controller's ``$this->format`` value.
If that is ``null``, it will try to negotiate the content type with what the
client asked for, defaulting to the first element (JSON by default) in the
``$supportedResponseFormats`` property within **app/Config/Format.php**.
* The data will be formatted according to the format. If the format is not JSON
and data is a string, it will be treated as HTML to send back to the client.

To define the formatter that is used, edit **Config/Format.php**. The ``$supportedResponseFormats`` contains a list of
.. note:: Prior to v4.5.0, due to a bug, if data is a string, it will be treated
as HTML even if the format is JSON.

To define the formatter that is used, edit **app/Config/Format.php**. The ``$supportedResponseFormats`` contains a list of
mime types that your application can automatically format the response for. By default, the system knows how to
format both XML and JSON responses:

Expand Down

0 comments on commit a286a7d

Please sign in to comment.