我正在尝试在 Xamarin.Forms (DryIoc.Microsoft.DependencyInjection) 上关注 Prism 上的 DryIoc 和 IServiceProvider但是我正在使用 RefitClientIHttpClientFactory
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)));
});
我已经添加了
protected override IContainerExtension CreateContainerExtension() => PrismContainerExtension.Current;
当我尝试向 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