jsonResponseProcessor function

void jsonResponseProcessor (
  1. Context context,
  2. dynamic result
)

ResponseProcessor to encode response value to json and also set mimetype to MimeType.json.

Implementation

void jsonResponseProcessor(Context context, dynamic result) {
  final info = context.route.info;

  final codec = context.codecFor(mimeType: MimeTypes.json);
  if (codec != null) result = codec.to(result);

  context.response = Response.json(result,
      statusCode: info.statusCode,
      mimeType: info.mimeType ?? MimeTypes.json,
      charset: info.charset ?? kDefaultCharset);
}