send method
Sends status with text as the body (UTF-8, Content-Length set)
and closes the response. contentType defaults to
text/plain; charset=utf-8; pass another for JSON or HTML text.
Implementation
Future<void> send(
int status,
String text, {
String contentType = 'text/plain; charset=utf-8',
}) {
final bytes = utf8.encode(text);
statusCode = status;
headers
..contentType = contentType
..contentLength = bytes.length;
add(bytes);
return close();
}