ServerResponse.okHtml constructor
ServerResponse.okHtml(})
Creates a successful 200 OK HTML response.
Implementation
factory ServerResponse.okHtml(
String html, {
Map<String, String>? headers,
String? etag,
DateTime? lastModified,
String? cacheControl,
}) {
final responseHeaders = <String, String>{
'Content-Type': 'text/html; charset=utf-8',
'Vary': 'Accept-Encoding',
'X-Content-Type-Options': 'nosniff',
if (headers != null) ...headers,
if (etag != null) 'ETag': etag,
if (lastModified != null)
'Last-Modified': lastModified.toUtc().toIso8601String(),
if (cacheControl != null) 'Cache-Control': cacheControl,
};
return ServerResponse(
statusCode: 200,
headers: responseHeaders,
body: html,
);
}