Refactor HTTP client name constant usage

Replaced the old HttpClientName constant in Constants.cs with a new Http.ClientName in the ReC.Application.Common.Constants namespace. Updated all references and using directives accordingly to improve code organization and maintainability.
This commit is contained in:
2025-12-12 12:54:57 +01:00
parent ea5389df85
commit bc700e2cd2
4 changed files with 10 additions and 9 deletions

View File

@@ -1,6 +0,0 @@
namespace ReC.Application.Common;
public static class Constants
{
public static readonly string HttpClientName = "HttpClient-" + Guid.NewGuid().ToString();
}

View File

@@ -0,0 +1,6 @@
namespace ReC.Application.Common.Constants;
public static class Http
{
public static readonly string ClientName = "HttpClient-" + Guid.NewGuid().ToString();
}

View File

@@ -2,8 +2,8 @@
using MediatR; using MediatR;
using Microsoft.Extensions.Configuration; using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.DependencyInjection;
using ReC.Application.Common;
using ReC.Application.Common.Behaviors; using ReC.Application.Common.Behaviors;
using ReC.Application.Common.Constants;
using ReC.Application.Common.Options; using ReC.Application.Common.Options;
using System.Reflection; using System.Reflection;
@@ -36,7 +36,7 @@ public static class DependencyInjection
cfg.LicenseKey = configOpt.LuckyPennySoftwareLicenseKey; cfg.LicenseKey = configOpt.LuckyPennySoftwareLicenseKey;
}); });
services.AddHttpClient(Constants.HttpClientName) services.AddHttpClient(Http.ClientName)
.ConfigurePrimaryHttpMessageHandler(() => new HttpClientHandler .ConfigurePrimaryHttpMessageHandler(() => new HttpClientHandler
{ {
UseDefaultCredentials = false UseDefaultCredentials = false

View File

@@ -1,6 +1,7 @@
using MediatR; using MediatR;
using Microsoft.Extensions.Configuration; using Microsoft.Extensions.Configuration;
using ReC.Application.Common; using ReC.Application.Common;
using ReC.Application.Common.Constants;
using ReC.Application.Common.Dto; using ReC.Application.Common.Dto;
using ReC.Application.Common.Exceptions; using ReC.Application.Common.Exceptions;
using ReC.Application.OutResults.Commands; using ReC.Application.OutResults.Commands;
@@ -31,7 +32,7 @@ public class InvokeRecActionCommandHandler(
{ {
var action = request.Action; var action = request.Action;
using var http = clientFactory.CreateClient(Constants.HttpClientName); using var http = clientFactory.CreateClient(Http.ClientName);
if (action.RestType is null) if (action.RestType is null)
throw new DataIntegrityException( throw new DataIntegrityException(