From bc700e2cd2f3cf97baec488a96cf38715d755f70 Mon Sep 17 00:00:00 2001 From: TekH Date: Fri, 12 Dec 2025 12:54:57 +0100 Subject: [PATCH] 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. --- src/ReC.Application/Common/Constants.cs | 6 ------ src/ReC.Application/Common/Constants/Http.cs | 6 ++++++ src/ReC.Application/DependencyInjection.cs | 4 ++-- .../RecActions/Commands/InvokeRecActionCommand.cs | 3 ++- 4 files changed, 10 insertions(+), 9 deletions(-) delete mode 100644 src/ReC.Application/Common/Constants.cs create mode 100644 src/ReC.Application/Common/Constants/Http.cs diff --git a/src/ReC.Application/Common/Constants.cs b/src/ReC.Application/Common/Constants.cs deleted file mode 100644 index 0679ba1..0000000 --- a/src/ReC.Application/Common/Constants.cs +++ /dev/null @@ -1,6 +0,0 @@ -namespace ReC.Application.Common; - -public static class Constants -{ - public static readonly string HttpClientName = "HttpClient-" + Guid.NewGuid().ToString(); -} diff --git a/src/ReC.Application/Common/Constants/Http.cs b/src/ReC.Application/Common/Constants/Http.cs new file mode 100644 index 0000000..ad99293 --- /dev/null +++ b/src/ReC.Application/Common/Constants/Http.cs @@ -0,0 +1,6 @@ +namespace ReC.Application.Common.Constants; + +public static class Http +{ + public static readonly string ClientName = "HttpClient-" + Guid.NewGuid().ToString(); +} diff --git a/src/ReC.Application/DependencyInjection.cs b/src/ReC.Application/DependencyInjection.cs index e04b494..8ea1847 100644 --- a/src/ReC.Application/DependencyInjection.cs +++ b/src/ReC.Application/DependencyInjection.cs @@ -2,8 +2,8 @@ using MediatR; using Microsoft.Extensions.Configuration; using Microsoft.Extensions.DependencyInjection; -using ReC.Application.Common; using ReC.Application.Common.Behaviors; +using ReC.Application.Common.Constants; using ReC.Application.Common.Options; using System.Reflection; @@ -36,7 +36,7 @@ public static class DependencyInjection cfg.LicenseKey = configOpt.LuckyPennySoftwareLicenseKey; }); - services.AddHttpClient(Constants.HttpClientName) + services.AddHttpClient(Http.ClientName) .ConfigurePrimaryHttpMessageHandler(() => new HttpClientHandler { UseDefaultCredentials = false diff --git a/src/ReC.Application/RecActions/Commands/InvokeRecActionCommand.cs b/src/ReC.Application/RecActions/Commands/InvokeRecActionCommand.cs index 303d1d7..0bd9114 100644 --- a/src/ReC.Application/RecActions/Commands/InvokeRecActionCommand.cs +++ b/src/ReC.Application/RecActions/Commands/InvokeRecActionCommand.cs @@ -1,6 +1,7 @@ using MediatR; using Microsoft.Extensions.Configuration; using ReC.Application.Common; +using ReC.Application.Common.Constants; using ReC.Application.Common.Dto; using ReC.Application.Common.Exceptions; using ReC.Application.OutResults.Commands; @@ -31,7 +32,7 @@ public class InvokeRecActionCommandHandler( { var action = request.Action; - using var http = clientFactory.CreateClient(Constants.HttpClientName); + using var http = clientFactory.CreateClient(Http.ClientName); if (action.RestType is null) throw new DataIntegrityException(