jsonParser static method
Implementation
static jsonParser(Req req, Res res, Function next) {
if (req.headers.contentType?.mimeType == 'application/json' &&
req.method != 'OPTIONS' &&
req.method != 'GET') {
String requestBody = "{}";
var bytes =
Uint8List.fromList(req.bodyStream.expand((chunk) => chunk).toList());
requestBody = utf8.decode(bytes);
req.body = jsonDecode(requestBody);
}
next();
}