Refactor HTTP method handling and cleanup
Refactored HTTP method handling by introducing a `ToHttpMethod` extension method in `HttpExtensions.cs` to convert string representations of HTTP methods to `HttpMethod` objects. Replaced manual `HttpMethod` instantiation with the new extension method in `InvokeRecActionCommandHandler` for improved readability and reusability. Removed unused `using` directives from `HttpExtensions.cs` and cleaned up the `namespace` declaration. Added a `using` directive for `ReC.Application.Common` in `InvokeRecActionCommand.cs` to support the new extension method.
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
using MediatR;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using ReC.Application.Common;
|
||||
using ReC.Application.Common.Dto;
|
||||
|
||||
namespace ReC.Application.RecActions.Commands;
|
||||
@@ -35,8 +36,7 @@ public class InvokeRecActionCommandHandler(
|
||||
return;
|
||||
}
|
||||
|
||||
var method = new HttpMethod(request.RestType.ToUpper());
|
||||
using var msg = new HttpRequestMessage(method, request.EndpointUri);
|
||||
using var msg = new HttpRequestMessage(request.RestType.ToHttpMethod(), request.EndpointUri);
|
||||
|
||||
using var response = await http.SendAsync(msg, cancel);
|
||||
var body = await response.Content.ReadAsStringAsync(cancel);
|
||||
|
||||
Reference in New Issue
Block a user