diff --git a/src/ReC.Application/Common/HttpExtensions.cs b/src/ReC.Application/Common/HttpExtensions.cs index f00ba3f..81e013b 100644 --- a/src/ReC.Application/Common/HttpExtensions.cs +++ b/src/ReC.Application/Common/HttpExtensions.cs @@ -1,4 +1,6 @@ -namespace ReC.Application.Common; +using System.Diagnostics.CodeAnalysis; + +namespace ReC.Application.Common; public static class HttpExtensions { @@ -18,4 +20,7 @@ public static class HttpExtensions public static HttpMethod ToHttpMethod(this string method) => _methods.TryGetValue(method, out var httpMethod) ? httpMethod : new HttpMethod(method); + + public static HttpRequestMessage ToHttpRequestMessage(this HttpMethod method, [StringSyntax(StringSyntaxAttribute.Uri)] string? requestUri) + => new(method, requestUri); } diff --git a/src/ReC.Application/RecActions/Commands/InvokeRecActionCommand.cs b/src/ReC.Application/RecActions/Commands/InvokeRecActionCommand.cs index adf3d0e..4c92de5 100644 --- a/src/ReC.Application/RecActions/Commands/InvokeRecActionCommand.cs +++ b/src/ReC.Application/RecActions/Commands/InvokeRecActionCommand.cs @@ -36,9 +36,11 @@ public class InvokeRecActionCommandHandler( return; } - using var msg = new HttpRequestMessage(request.RestType.ToHttpMethod(), request.EndpointUri); + using var reqMsg = request.RestType + .ToHttpMethod() + .ToHttpRequestMessage(request.EndpointUri); - using var response = await http.SendAsync(msg, cancel); + using var response = await http.SendAsync(reqMsg, cancel); var body = await response.Content.ReadAsStringAsync(cancel); var headers = response.Headers.ToDictionary(); }