Refactor to use IHttpClientFactory and remove ApiOptions
Replaced direct injection of HttpClient with IHttpClientFactory across the codebase to improve HTTP client management and align with best practices. Removed dependency on ApiOptions and IOptions<ApiOptions> in multiple services, simplifying constructors and reducing configuration complexity. Updated FontLoader to use IHttpClientFactory for font loading with relative paths. Adjusted comments and documentation to reflect these changes. Cleaned up unused using directives related to ApiOptions.
This commit is contained in:
@@ -2,10 +2,15 @@
|
||||
|
||||
namespace EnvelopeGenerator.Server.Client.Services;
|
||||
|
||||
public static class FontLoader {
|
||||
public async static Task LoadFonts(HttpClient httpClient, List<string> fontNames) {
|
||||
foreach(var fontName in fontNames) {
|
||||
var fontBytes = await httpClient.GetByteArrayAsync($"fonts/{fontName}");
|
||||
public static class FontLoader
|
||||
{
|
||||
public static async Task LoadFonts(IHttpClientFactory httpClientFactory, List<string> fontNames)
|
||||
{
|
||||
using var httpClient = httpClientFactory.CreateClient("EnvelopeGenerator.Server");
|
||||
|
||||
foreach (var fontName in fontNames)
|
||||
{
|
||||
var fontBytes = await httpClient.GetByteArrayAsync($"/fonts/{fontName}");
|
||||
DXFontRepository.Instance.AddFont(fontBytes);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user