serialize method
Serializes data to the response.
Implementation
Future<bool> serialize(value, {MediaType? contentType}) async {
if (!isOpen) {
throw closed();
}
this.contentType = contentType ?? MediaType('application', 'json');
var text = await serializer(value);
if (text.isEmpty) return true;
write(text);
await close();
return false;
}