Add CreateFakeAction endpoint and update command defaults
The ActionController class was updated to include a new CreateFakeAction endpoint. This endpoint accepts optional parameters (endpointUri, type, and bodyQuery) and sends a CreateRecActionCommand with hardcoded and default values. The CreateRecActionCommand record was modified to remove default values for ProfileId, Type, and BodyQuery. These properties now require explicit initialization, with Type and BodyQuery marked as non-nullable using the null! syntax. These changes improve flexibility and add support for creating "fake" actions via the new endpoint.
This commit is contained in:
@@ -19,6 +19,24 @@ public class ActionController(IMediator mediator) : ControllerBase
|
||||
public async Task<IActionResult> CreateAction([FromBody] CreateRecActionCommand command)
|
||||
{
|
||||
await mediator.Send(command);
|
||||
|
||||
return CreatedAtAction(nameof(CreateAction), null);
|
||||
}
|
||||
|
||||
[HttpPost("fake")]
|
||||
public async Task<IActionResult> CreateFakeAction(
|
||||
string? endpointUri = null,
|
||||
string type = "GET",
|
||||
string bodyQuery = "SELECT NULL AS REQUEST_BODY;")
|
||||
{
|
||||
await mediator.Send(new CreateRecActionCommand()
|
||||
{
|
||||
ProfileId = 2,
|
||||
EndpointUri = endpointUri,
|
||||
Type = type,
|
||||
BodyQuery = bodyQuery
|
||||
});
|
||||
|
||||
return CreatedAtAction(nameof(CreateFakeAction), null);
|
||||
}
|
||||
}
|
||||
@@ -6,7 +6,7 @@ namespace ReC.Application.RecActions.Commands;
|
||||
|
||||
public record CreateRecActionCommand : IRequest
|
||||
{
|
||||
public long ProfileId { get; init; } = 2;
|
||||
public long ProfileId { get; init; }
|
||||
|
||||
public bool Active { get; init; } = true;
|
||||
|
||||
@@ -14,11 +14,11 @@ public record CreateRecActionCommand : IRequest
|
||||
|
||||
public string? EndpointUri { get; init; }
|
||||
|
||||
public string Type { get; init; } = "GET";
|
||||
public string Type { get; init; } = null!;
|
||||
|
||||
public string? HeaderQuery { get; init; }
|
||||
|
||||
public string BodyQuery { get; init; } = "SELECT NULL AS REQUEST_BODY;";
|
||||
public string BodyQuery { get; init; } = null!;
|
||||
}
|
||||
|
||||
public class CreateRecActionCommandHandler(ISender sender) : IRequestHandler<CreateRecActionCommand>
|
||||
|
||||
Reference in New Issue
Block a user