I am trying to follow DryIoc and IServiceProvider on Prism for Xamarin.Forms (DryIoc.Microsoft.DependencyInjection) however I am using RefitClient for IHttpClientFactory
containerRegistry.RegisterServices(services =>
{
services.AddTransient<HttpLoggingHandler>();
services.AddTransient<AuthorizationDelegatingHandler>();
services.AddRefitClient<IMyApi>()
.ConfigureHttpClient(c =>
c.BaseAddress =
new Uri(apiBaseUrl))
.AddHttpMessageHandler<AuthorizationDelegatingHandler>()
.AddHttpMessageHandler<HttpLoggingHandler>()
.AddTransientHttpErrorPolicy(builder => builder.WaitAndRetryAsync(new[]
{
TimeSpan.FromMilliseconds(300),
TimeSpan.FromSeconds(600),
TimeSpan.FromSeconds(800)
}))
.AddTransientHttpErrorPolicy(
p => p.CircuitBreakerAsync(5, TimeSpan.FromSeconds(30)));
});
I have added
protected override IContainerExtension CreateContainerExtension() => PrismContainerExtension.Current;
When I try to make a request with IMyApi.
BaseAddress must be set on the HttpClient instance
at Refit.RequestBuilderImplementation+<>c__DisplayClass14_0`2[T,TBody].<BuildCancellableTaskFuncForMethod>b__0 (System.Net.Http.HttpClient client, System.Threading.CancellationToken ct, System.Object[] paramList) [0x00030] in /_/Refit/RequestBuilderImplementation.cs:236