-
Notifications
You must be signed in to change notification settings - Fork 173
About response formatters
jeff-h edited this page Dec 15, 2015
·
3 revisions
RESTful abstracts the code that generates the final response output into response formatters.
At admin/config/services/restful
you can specify which formatter RESTful should use by default.
However, requests may specify a specific formatter by sending the Accept
header.
For example, to request JSON-API:
Accept: application/vnd.api+json; charset=utf-8
The correct Accept
header to send can be found in the corresponding formatter class. For the above example this would be restful/src/Plugin/formatter/FormatterJsonApi.php
which defines on line 41 the following:
protected $contentType = 'application/vnd.api+json; charset=utf-8';
Custom formatters are possible by extending one of the formatter classes from restful/src/Plugin/formatter