Add enhancements to ActionController and CreateFakeAction
Refactored ActionController to include IMediator dependency in the constructor. Updated CreateFakeAction method to: - Set a default value for `endpointUri`. - Add an optional `endpointPath` parameter and logic to construct a full URI. - Include the `Active` property in CreateRecActionCommand. - Ensure `endpointUri` is non-nullable. Also added the `System.IO` namespace for potential future use.
This commit is contained in:
parent
4d593e8a8e
commit
1000be0c89
@ -1,6 +1,7 @@
|
||||
using MediatR;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using ReC.Application.RecActions.Commands;
|
||||
using System.IO;
|
||||
|
||||
namespace ReC.API.Controllers;
|
||||
|
||||
@ -25,16 +26,21 @@ public class ActionController(IMediator mediator) : ControllerBase
|
||||
|
||||
[HttpPost("fake")]
|
||||
public async Task<IActionResult> CreateFakeAction(
|
||||
string? endpointUri = null,
|
||||
string endpointUri = "https://jsonplaceholder.typicode.com/posts",
|
||||
string? endpointPath = null,
|
||||
string type = "GET",
|
||||
string bodyQuery = "SELECT NULL AS REQUEST_BODY;")
|
||||
{
|
||||
if (endpointPath is not null)
|
||||
endpointUri = new Uri(new Uri(endpointUri.TrimEnd('/') + "/"), endpointPath.TrimStart('/')).ToString();
|
||||
|
||||
await mediator.Send(new CreateRecActionCommand()
|
||||
{
|
||||
ProfileId = 2,
|
||||
EndpointUri = endpointUri,
|
||||
Type = type,
|
||||
BodyQuery = bodyQuery
|
||||
BodyQuery = bodyQuery,
|
||||
Active = true,
|
||||
});
|
||||
|
||||
return CreatedAtAction(nameof(CreateFakeAction), null);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user