BloomResponse.html constructor

BloomResponse.html(
  1. String html, {
  2. int statusCode = 200,
  3. Map<String, String>? headers,
})

Helper factory constructor for HTML responses.

Sets Content-Type: text/html; charset=utf-8 and encodes html as UTF-8 bytes.

Example

return BloomResponse.html('<h1>Hello Bloom</h1>');

Implementation

factory BloomResponse.html(
  String html, {
  int statusCode = 200,
  Map<String, String>? headers,
}) {
  final finalHeaders = <String, String>{
    'content-type': 'text/html; charset=utf-8',
    ...?headers,
  };
  return BloomResponse(
    statusCode: statusCode,
    headers: finalHeaders,
    body: Uint8List.fromList(utf8.encode(html)),
  );
}