From c16d58788ad2bf18406dd3d14b0b9fe968c9612f Mon Sep 17 00:00:00 2001 From: Developer 02 Date: Wed, 26 Nov 2025 17:34:42 +0100 Subject: [PATCH] Refactor switch statement to switch expression Replaced the `switch` statement with a `switch` expression to handle HTTP methods (`GET`, `POST`, `PUT`, `DELETE`). This refactoring reduces boilerplate code and improves readability by directly assigning the HTTP request result to the `response` variable, eliminating the need for multiple `using` and `break` statements. --- .../Commands/InvokeRecActionCommand.cs | 31 +++++-------------- 1 file changed, 7 insertions(+), 24 deletions(-) diff --git a/src/ReC.Application/RecActions/Commands/InvokeRecActionCommand.cs b/src/ReC.Application/RecActions/Commands/InvokeRecActionCommand.cs index a7faa2c..07048fa 100644 --- a/src/ReC.Application/RecActions/Commands/InvokeRecActionCommand.cs +++ b/src/ReC.Application/RecActions/Commands/InvokeRecActionCommand.cs @@ -25,31 +25,14 @@ public class InvokeRecActionCommandHandler(ISender sender) : IRequestHandler await http.GetAsync(action.EndpointUri, cancel), + "POST" => await http.PostAsync(action.EndpointUri, null, cancel), + "PUT" => await http.PutAsync(action.EndpointUri, null, cancel), + "DELETE" => await http.DeleteAsync(action.EndpointUri, cancel), + _ => throw new BadRequestException($"The REST type {action.RestType} is not supported.") + }; } } } \ No newline at end of file