Refactor: remove HttpExtensions and inline HTTP method mapping

Removed HttpExtensions.cs and its extension methods for RestType-to-HttpMethod conversion. Introduced a private static CreateHttpRequestMessage method in InvokeRecActionViewCommandHandler to handle HTTP method mapping and request creation directly, reducing indirection and simplifying dependencies.
This commit is contained in:
2026-03-02 14:31:38 +01:00
parent ec119a3045
commit 0e7870b556
2 changed files with 21 additions and 32 deletions

View File

@@ -1,29 +0,0 @@
using ReC.Domain.Constants;
using System.Diagnostics.CodeAnalysis;
namespace ReC.Application.Common;
public static class HttpExtensions
{
private static readonly Dictionary<RestType, HttpMethod> _methods = new()
{
[RestType.Get] = HttpMethod.Get,
[RestType.Post] = HttpMethod.Post,
[RestType.Put] = HttpMethod.Put,
[RestType.Delete] = HttpMethod.Delete,
[RestType.Patch] = HttpMethod.Patch,
[RestType.Head] = HttpMethod.Head,
[RestType.Options] = HttpMethod.Options,
[RestType.Trace] = HttpMethod.Trace,
[RestType.Connect] = HttpMethod.Connect
};
public static HttpMethod ToHttpMethod(this RestType method) => !method.IsValid()
? throw new ArgumentOutOfRangeException(nameof(method), $"The RestType value '{method}' is not valid.")
: _methods.TryGetValue(method, out var httpMethod)
? httpMethod
: new HttpMethod(method.ToHttpMethodName());
public static HttpRequestMessage ToHttpRequestMessage(this HttpMethod method, [StringSyntax(StringSyntaxAttribute.Uri)] string? requestUri)
=> new(method, requestUri);
}