I'm just trying to create a simple test where I use DelegateHandlers
to instantiate a HttpClient
without bringing Asp.net Core packages.
I have 2 deletage handlers
ThrottlingDelegatingHandler
PolicyHttpMessageHandler
(from Polly package)
How can I combine both and pass to the HttpClient
?
var policy = HttpPolicyExtensions.HandleTransientHttpError().CircuitBreakerAsync(5, TimeSpan.FromSeconds(30));
var pollyHandler = new PolicyHttpMessageHandler(policy);
var http = new HttpClient(new ThrottlingDelegatingHandler(MaxParallelism, pollyHandler));
The above gives me an error: System.InvalidOperationException : The inner handler has not been assigned.
The PolicyHttpMessageHandler
does not have a constructor where I can pass the innerHandler
.
How can I accomplish this?