Future receive(Request req)

Delivers req to this instance to be processed.

This method is the entry point of a Request into this RequestController. By default, it invokes this controller's processRequest method within a try-catch block that guarantees an HTTP response will be sent for Request.

Source

Future receive(Request req) async {
  if (req.isPreflightRequest) {
    return _handlePreflightRequest(req);
  }

  var result;
  try {
    result = await processRequest(req);
    if (result is Response) {
      await _sendResponse(req, result, includeCORSHeaders: true);
      logger.info(req.toDebugString());
      return null;
    }
  } catch (any, stacktrace) {
    var shouldRethrow = await handleError(req, any, stacktrace);
    if (letUncaughtExceptionsEscape && shouldRethrow) {
      rethrow;
    }

    return null;
  }

  if (result == null) {
    return null;
  }

  return nextController?.receive(result);
}