body<T> method

Future<T?> body<T>({
  1. ObjectMapper? om,
})

Get the body of the request, it's get parsed with the ObjectMapper in the process It's algo get cached in case the method is called multiple times

Implementation

Future<T?> body<T>({ObjectMapper? om}) async {
  if (_cachedBody == null || _cachedBody is! T) {
    String rawString = await readAsString(encoding);
    _cachedBody = (om ?? Winter.instance.context.objectMapper)
        .deserialize<T>(rawString);
  }
  return _cachedBody as T;
}