private void GivenCacheKeyFromContext(DownstreamContext context) { string generatedCacheKey = _cacheKeyGenerator.GenerateRequestCacheKey(context); string cachekey = MD5Helper.GenerateMd5("GET-https://some.url/blah?abcd=123"); generatedCacheKey.ShouldBe(cachekey); }
private void ThenTheContentTypeHeaderIsCached() { string cacheKey = MD5Helper.GenerateMd5("GET-https://some.url/blah?abcd=123"); var result = _cacheManager.Get(cacheKey, "kanken"); var header = result.ContentHeaders["Content-Type"]; header.First().ShouldBe("application/json"); }
private string GenerateRequestCacheKey(DownstreamContext context) { string hashedContent = null; StringBuilder downStreamUrlKeyBuilder = new StringBuilder($"{context.DownstreamRequest.Method}-{context.DownstreamRequest.OriginalString}"); if (context.DownstreamRequest.Content != null) { string requestContentString = Task.Run(async() => await context.DownstreamRequest.Content?.ReadAsStringAsync()).Result; downStreamUrlKeyBuilder.Append(requestContentString); } hashedContent = MD5Helper.GenerateMd5(downStreamUrlKeyBuilder.ToString()); return(hashedContent); }