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.

If this method returns a Response, it will be sent as the response for req and req will not be passed to any other controllers.

If this method returns req, req will be passed to nextController.

If this method returns null, req is not passed to any other controller and is not responded to. You must respond to req through Request.innerRequest.

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;
  }
}