-
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.
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. It sets the content header with the corresponding mime-type. Then, depending on the content type, it does the following:
- TEXT and HTML: all simple content (
IsSimpleValue()) is concatenated and written to the output. Complex content like structs and arrays is ignored. - 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.