handleRequest method

  1. @override
void handleRequest()

Implementation

@override
void handleRequest() {
  on<JsonRestRequest>(
    (request, send) async {
      final data = await _restService.request<Map<String, dynamic>>(
        method: request.method,
        path: request.path,
        data: request.data,
        headers: request.headers,
      );
      send(JsonRestSuccessResponse(data: data));
    },
  );
  on<MultiPartRestRequest>(
    (request, send) async {
      final data = await _restService.multipartRequest(
        method: request.method,
        path: request.path,
        data: request.data,
        headers: request.headers,
      );
      send(JsonRestSuccessResponse(data: data));
    },
  );
  on<BytesRestRequest>(
    (request, send) async {
      final data = await _restService.request<Uint8List>(
        method: request.method,
        path: request.path,
        data: request.data,
        headers: request.headers,
      );
      send(BytesRestSuccessResponse(data: data));
    },
  );
  on<BinaryDataSrcRestRequest>(
    (request, send) async {
      final binaryData = await XFile(request.src).readAsBytes();
      final data = await _restService.binaryRequest(
        method: request.method,
        path: request.path,
        data: binaryData,
        headers: request.headers,
      );
      send(JsonRestSuccessResponse(data: data));
    },
  );
  on<BinaryDataRestRequest>(
    (request, send) async {
      final data = await _restService.binaryRequest(
        method: request.method,
        path: request.path,
        data: request.binaryData,
        headers: request.headers,
      );
      send(JsonRestSuccessResponse(data: data));
    },
  );
}