Class SimpleHttpClientFactory
- Namespace
- The.Composition
- Assembly
- Instagile.dll
An implementation of IHttpClientFactory usable without referencing ASP.NET Core.
public sealed class SimpleHttpClientFactory : IHttpClientFactory
- Inheritance
-
SimpleHttpClientFactory
- Implements
- Inherited Members
Constructors
SimpleHttpClientFactory(params (string name, Action<HttpClient> config)[])
public SimpleHttpClientFactory(params (string name, Action<HttpClient> config)[] namedConfigs)
Parameters
namedConfigs(string name, Action<HttpClient> config)[]
Fields
Default
public static readonly IHttpClientFactory Default
Field Value
Methods
CreateClient(string)
Creates and configures an HttpClient instance using the configuration that corresponds
to the logical name specified by name.
public HttpClient CreateClient(string name)
Parameters
namestringThe logical name of the client to create.
Returns
- HttpClient
A new HttpClient instance.
Remarks
Each call to CreateClient(string) is guaranteed to return a new HttpClient instance. It is generally not necessary to dispose of the HttpClient as the IHttpClientFactory tracks and disposes resources used by the HttpClient.
Callers are also free to mutate the returned HttpClient instance's public properties as desired.
WithBaseAddress(string)
public static IHttpClientFactory WithBaseAddress(string baseAddress)
Parameters
baseAddressstring
Returns
WithBaseAddress(Uri)
public static IHttpClientFactory WithBaseAddress(Uri baseAddress)
Parameters
baseAddressUri