bodyDecode<T> method

Future<T> bodyDecode <T>()

Deserializes body by mimetype using _serializers

Implementation

Future<T> bodyDecode<T>() async {
  final codec = _serializers[mimeType.mimeType];
  if (codec is CodecRepo<String>) {
    return codec.decode<T>(await bodyAsText());
  } else if (codec is CodecRepo<List<int>>) {
    return codec.decode<T>(await body);
  }
  throw Exception("Do not have codec for mimetype: ${mimeType.mimeType}");
}