JokerResponse.text constructor

JokerResponse.text(
  1. String text, {
  2. int statusCode = 200,
  3. Map<String, String> headers = const {},
  4. Duration? delay,
})

Creates a successful response with text body

Example:

final response = JokerResponse.text('Hello, World!');

Implementation

factory JokerResponse.text(
  String text, {
  int statusCode = 200,
  Map<String, String> headers = const {},
  Duration? delay,
}) {
  final textHeaders = {
    'content-type': 'text/plain; charset=utf-8',
    ...headers,
  };
  return JokerResponse(
    statusCode: statusCode,
    headers: textHeaders,
    body: text,
    delay: delay,
  );
}