BloomResponse.text constructor
Helper factory constructor for plain text responses.
Sets Content-Type: text/plain; charset=utf-8 and encodes text as UTF-8 bytes.
Example
return BloomResponse.text('pong');
Implementation
factory BloomResponse.text(
String text, {
int statusCode = 200,
Map<String, String>? headers,
}) {
final finalHeaders = <String, String>{
'content-type': 'text/plain; charset=utf-8',
...?headers,
};
return BloomResponse(
statusCode: statusCode,
headers: finalHeaders,
body: Uint8List.fromList(utf8.encode(text)),
);
}