1. @override
Future<RequestOrResponse> processRequest(Request req)

Overridden by subclasses to modify or respond to an incoming request.

Subclasses override this method to provide their specific handling of a request. A RequestController should either modify or respond to the request. For concrete subclasses of RequestController - like HTTPController - this method has already been implemented.

RequestControllers should return a Response from this method if they responded to the request. If a RequestController does not respond to the request, but instead modifies it, this method must return the same Request.

Source

@override
Future<RequestOrResponse> processRequest(Request req) async {
  try {
    request = req;

    var preprocessedResult = await willProcessRequest(req);
    Response response;
    if (preprocessedResult is Request) {
      response = await _process();
    } else if (preprocessedResult is Response) {
      response = preprocessedResult;
    } else {
      response = new Response.serverError(
          body: {"error": "Preprocessing request did not yield result"});
    }

    return response;
  } on InternalControllerException catch (e) {
    var response = e.response;
    return response;
  }
}