onHandle method Null safety

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

Called every time an handling is needed.

Do not call this function, it is called from SparkREST from you.

Implementation

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