Class SlimHttpClientFactoryOptions
- Namespace
- Cuemon.Extensions.Net.Http
- Assembly
- 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
SlimHttpClientFactoryOptions()
Initializes a new instance of the SlimHttpClientFactoryOptions class.
public SlimHttpClientFactoryOptions()
Remarks
The following table shows the initial property values for an instance of SlimHttpClientFactoryOptions.
| Property | Initial Value |
|---|---|
| HandlerLifetime | TimeSpan.FromMinutes(5); |
Properties
HandlerLifetime
Gets or sets the lifetime of the HttpMessageHandler.
public TimeSpan HandlerLifetime { get; set; }
Property Value
- TimeSpan
The lifetime of the HttpMessageHandler.