sendCustom method

void sendCustom({
  1. required String content,
  2. required ContentType contentType,
  3. Map<String, String>? headers,
})

Sends a custom response with full control.

Implementation

void sendCustom({
  required String content,
  required ContentType contentType,
  Map<String, String>? headers,
}) {
  if (_sent) return;

  _headers.setContentType(contentType);
  headers?.forEach((key, value) {
    _headers.setHeader(key, value);
  });

  _response.add(_safeUtf8Encode(content));
  _closeResponse();
}