setResponseFormat method
Sets the response format to the specified type
.
The supported types are:
- 'html': Sets the content type to 'text/html'
- 'json': Sets the content type to 'application/json'
- 'text': Sets the content type of response to 'text/plain'
- 'null': Sets the status code to 204 (No Content)
Throws an ArgumentError if an invalid type
is provided.
Implementation
void setResponseFormat(String type) {
var headerValue = _contentTypes[type];
if (headerValue != null) {
appendDefaultResponseHeader(_request.response.headers, headerValue);
}
}