public Task <VendorOrders> Handle(GetVendorOrdersCommand request, CancellationToken cancellationToken)
        {
            //Call http client that have circuit breaker and retry implemented
            string uri      = "http://businessfrayms.com/api/Order?vendorId=" + request.VendorID;
            var    response = _client.Get(uri);

            return(null);
        }
Esempio n. 2
0
        public async Task <IActionResult> Get()
        {
            // HttpClient clnt = new HttpClient();
            // var response = clnt.GetAsync("http://localhost:7637/api/values").Result;

            //Specify the name of the Response. If the method is taking parameter, we can append the actual parameter to cache unique responses separately
            Context policyExecutionContext = new Context($"GetUsers");

            var response = _cachePolicy.Execute(() => _resilientClient.Get("http://localhost:7637/api/values"), policyExecutionContext);

            if (response.IsSuccessStatusCode)
            {
                var result = response.Content.ReadAsStringAsync();
                return(Ok(result));
            }

            return(StatusCode((int)response.StatusCode, response.Content.ReadAsStringAsync()));
        }