onHandle method Null safety

  1. @override
Future<Response> onHandle(
  1. Request request
)

Method called when something should be handled in this class

Implementation

@override
Future<Response> onHandle(Request request) async {
  var methodRouter = this[request.uri.path];
  if (methodRouter == null) {
    return Response(
      request: request,
      statusCode: 404,
      headers: {},
      contentType: ContentType.json,
      body: '{"message":"The uri does not exists"}',
    );
  }
  return methodRouter.onHandle(request);
}