Add support for more HTTP methods

Extended the switch expression in `InvokeRecActionCommand.cs` to handle additional HTTP methods: "PATCH", "HEAD", "OPTIONS", and "TRACE".
Implemented the appropriate asynchronous HTTP requests using `HttpClient`.
"PATCH" uses `http.PatchAsync`, while "HEAD", "OPTIONS", and "TRACE" use `http.SendAsync` with a new `HttpRequestMessage`.
A `BadRequestException` is thrown for unsupported methods.
This commit is contained in:
Developer 02 2025-11-26 17:34:52 +01:00
parent c16d58788a
commit 904448ca45

View File

@ -31,6 +31,10 @@ public class InvokeRecActionCommandHandler(ISender sender) : IRequestHandler<Inv
"POST" => await http.PostAsync(action.EndpointUri, null, cancel),
"PUT" => await http.PutAsync(action.EndpointUri, null, cancel),
"DELETE" => await http.DeleteAsync(action.EndpointUri, cancel),
"PATCH" => await http.PatchAsync(action.EndpointUri, null, cancel),
"HEAD" => await http.SendAsync(new HttpRequestMessage(HttpMethod.Head, action.EndpointUri), cancel),
"OPTIONS" => await http.SendAsync(new HttpRequestMessage(HttpMethod.Options, action.EndpointUri), cancel),
"TRACE" => await http.SendAsync(new HttpRequestMessage(HttpMethod.Trace, action.EndpointUri), cancel),
_ => throw new BadRequestException($"The REST type {action.RestType} is not supported.")
};
}