SlimHttpClientFactoryOptions Class
Definition
- Namespace
- Cuemon.Extensions.Net.Http
- Assemblies
- Cuemon.Extensions.Net.dll
Configuration options for SlimHttpClientFactory.
public class SlimHttpClientFactoryOptions : IParameterObject
- Inheritance
-
SlimHttpClientFactoryOptions
- Implements
- Extension Methods
Examples
The following example demonstrates how to configure
using System;
using System.Net.Http;
using Cuemon.Extensions.Net.Http;
namespace MyApp.Examples;
public class SlimHttpClientFactoryOptionsExample
{
public void Demonstrate()
{
// Direct instantiation of SlimHttpClientFactoryOptions
var factoryOptions = new SlimHttpClientFactoryOptions
{
HandlerLifetime = TimeSpan.FromSeconds(30)
};
var factory = new SlimHttpClientFactory(
() => new HttpClientHandler(),
o =>
{
o.HandlerLifetime = TimeSpan.FromSeconds(30);
});
// Create a named client
using var client = factory.CreateClient("MyApi");
client.BaseAddress = new Uri("https://api.example.com");
Console.WriteLine($"Client ready: {client.BaseAddress}");
}
}
Constructors
| Name | Description |
|---|---|
| SlimHttpClientFactoryOptions() | Initializes a new instance of the SlimHttpClientFactoryOptions class. |
Properties
| Name | Description |
|---|---|
| HandlerLifetime | Gets or sets the lifetime of the HttpMessageHandler. |