-
Notifications
You must be signed in to change notification settings - Fork 3
Response object
neoneo edited this page Jan 25, 2012
·
4 revisions
At the beginning of the request handling by CFlow, a Response object is created. This object gathers all content that is generated by the views. Content can have different types. Currently only 'TEXT', 'HTML' and 'JSON' are implemented.
Views have direct access to this object.
The Response object has the following methods:
Returns the content type of the response: HTML, JSON or TEXT.
Sets the content type of the response: HTML, JSON or TEXT.
Returns the mime-type of the response.
Appends content to the response. The content must be a string, or be serializable to JSON.
Deletes all content from the response.
Outputs the content to the page. Depending on the content type, it does the following:
- TEXT and HTML: all string content is concatenated and written to the output.
- JSON: if there is exactly one content element in the response, serializes that element to JSON. If there are multiple content elements, it serializes them all in an array.