public async Task <ActionResult <List <ActionApiCallResultDTO> > > StopRecordingAsync(string serviceCode, CancellationToken cancellationToken) { if (string.IsNullOrWhiteSpace(serviceCode)) { throw new ArgumentNullException(nameof(serviceCode)); } var actionResult = await _actionApiService.StopRecordingAsync(serviceCode, cancellationToken); // save captured routes var cachekey = KakaduConstants.GetFoundRoutesKey(serviceCode); var capturedRoutes = await _cache.GetAsync <List <KnownRouteDTO> >(cachekey, token : cancellationToken); if (capturedRoutes != null && capturedRoutes.Any()) { var entities = _mapper.Map <List <KnownRouteModel> >(capturedRoutes); // TODO: go through replies, if compressed, store them in a raw form and make sure they're encoded when sending back from cache /* * if (contentEncoding == "gzip") * { * content = DecompressGZip(content); * if (msg.Content?.Headers?.Contains("Content-Encoding") ?? false) * { * msg.Content?.Headers?.Remove("Content-Encoding"); * contentEncoding = string.Empty; * } * } */ _serviceService.AddKnownRoutes(serviceCode, entities); } // clear cache await _cache.RemoveAsync(KakaduConstants.GetServiceKey(serviceCode), cancellationToken); return(Ok(actionResult)); }