GetCookies-Methode hinzugefügt. Test für http-Dienst hinzugefügt
This commit is contained in:
@@ -8,7 +8,7 @@ namespace DigitalData.Core.Client
|
||||
public class BaseHttpClientService : IBaseHttpClientService
|
||||
{
|
||||
protected readonly HttpClient _client;
|
||||
protected readonly CookieContainer _cookies;
|
||||
protected readonly CookieContainer _cookies;
|
||||
|
||||
[StringSyntax("Uri")]
|
||||
public string Uri { get; init; }
|
||||
@@ -20,6 +20,8 @@ namespace DigitalData.Core.Client
|
||||
Uri = clientOptions.Value.Uri;
|
||||
}
|
||||
|
||||
public CookieCollection GetCookies(string route = "") => _cookies.GetCookies(uri: new Uri(Uri + route));
|
||||
|
||||
public async Task<HttpResponseMessage> FetchAsync(
|
||||
string route = "",
|
||||
HttpMethod? method = null,
|
||||
|
||||
@@ -17,7 +17,7 @@ namespace DigitalData.Core.Client
|
||||
return services;
|
||||
}
|
||||
|
||||
public static IServiceCollection AddHttpClientService<TClientOptions>(this IServiceCollection services, Action<TClientOptions>? clientOptions = null, bool setAsDefault = false)
|
||||
public static IServiceCollection AddHttpClientService<TClientOptions>(this IServiceCollection services, Action<TClientOptions>? clientOptions = null, bool setAsDefaultBase = false)
|
||||
where TClientOptions : HttpClientOptions, new()
|
||||
{
|
||||
services.TryAddSingleton<HttpClient>();
|
||||
@@ -25,7 +25,7 @@ namespace DigitalData.Core.Client
|
||||
services.AddSingleton<IHttpClientService<TClientOptions>, HttpClientService<TClientOptions>>();
|
||||
services.Configure(clientOptions ?? (_ => { }));
|
||||
|
||||
if (setAsDefault)
|
||||
if (setAsDefaultBase)
|
||||
services.AddSingleton<IBaseHttpClientService, HttpClientService<TClientOptions>>();
|
||||
|
||||
return services;
|
||||
|
||||
Reference in New Issue
Block a user