Quantcast
Channel: Active questions tagged blazor - Stack Overflow
Viewing all articles
Browse latest Browse all 4839

How to use Polly with Refit?

$
0
0

I am not configuring my Refit client using the services in Startup. I am doing the following:

public Task<IMyService> GetService(){    var retryPolicy = HttpPolicyExtensions        .HandleTransientHttpError()        .Or<TimeoutRejectedException>()        .WaitAndRetryAsync(2, _ => TimeSpan.FromMilliseconds(500));    var timeoutPolicy = Policy        .TimeoutAsync<HttpResponseMessage>(TimeSpan.FromMilliseconds(500));    return Task.FromResult(RestService.For<IMyService>(new HttpClient((DelegatingHandler)myHandler)    {        BaseAddress = new Uri(myUrl)    },        new RefitSettings() {}    ));}

I need to add the Polly policies to the client. How can I do this when creating a client with RestService.For<>?


Viewing all articles
Browse latest Browse all 4839

Trending Articles