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,21 +2,15 @@ using System.Net.Http;
|
||||
using System.Net.Http.Json;
|
||||
using System.Text.Json;
|
||||
using EnvelopeGenerator.Server.Client.Models;
|
||||
using EnvelopeGenerator.Server.Client.Options;
|
||||
using Microsoft.Extensions.Options;
|
||||
|
||||
namespace EnvelopeGenerator.Server.Client.Services;
|
||||
|
||||
/// <summary>
|
||||
/// Retrieves annotation positions from the API.
|
||||
/// The URL is composed as <c>{BaseUrl}/api/Annotation/{envelopeKey}</c>.
|
||||
/// During development, <c>BaseUrl</c> is empty so the request resolves to the
|
||||
/// YARP-proxied route on the same origin, which currently serves
|
||||
/// <c>fake-data/annotations.json</c>. To switch to real data, update the
|
||||
/// YARP route in <c>yarp.json</c> — no code change required.
|
||||
/// Uses relative paths (/api/Annotation/{envelopeKey}).
|
||||
/// </summary>
|
||||
[Obsolete("Use SignatureService.")]
|
||||
public class AnnotationService(IHttpClientFactory httpClientFactory, IOptions<ApiOptions> apiOptions)
|
||||
public class AnnotationService(IHttpClientFactory httpClientFactory)
|
||||
{
|
||||
private static readonly JsonSerializerOptions _jsonOptions = new(JsonSerializerDefaults.Web);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user