diff --git a/samples/EasyWay.Samples/Queries/SampleQuery.cs b/samples/EasyWay.Samples/Queries/SampleQuery.cs index 29e61d8..c0a676e 100644 --- a/samples/EasyWay.Samples/Queries/SampleQuery.cs +++ b/samples/EasyWay.Samples/Queries/SampleQuery.cs @@ -2,6 +2,8 @@ { public class SampleQuery : Query { - public string Name { get; set; } + public required string Name { get; init; } + + public required int Age { get; init; } } } diff --git a/source/EasyWay.WebApi/RcpStyleExtensions.cs b/source/EasyWay.WebApi/RcpStyleExtensions.cs index ee4e9f5..a7ee2db 100644 --- a/source/EasyWay.WebApi/RcpStyleExtensions.cs +++ b/source/EasyWay.WebApi/RcpStyleExtensions.cs @@ -14,7 +14,7 @@ public static WebKernel MapQuery(this WebKernel web where TQuery : Query where TReadModel : ReadModel { - webKernel.App.MapPost(typeof(TModule).Name + "/_queries/" + typeof(TQuery).Name, async ([FromBody] TQuery query, IModuleExecutor executor, CancellationToken cancellationToken) => + webKernel.App.MapGet("api/" + typeof(TModule).Name + "/" + typeof(TQuery).Name, async ([AsParameters] TQuery query, IModuleExecutor executor, CancellationToken cancellationToken) => { var queryResult = await executor.Execute(query, cancellationToken); @@ -35,7 +35,7 @@ public static WebKernel MapCommand(this WebKernel webKernel) where TModule : EasyWayModule where TCommand : Command { - webKernel.App.MapPost(typeof(TModule).Name + "/_commands/" + typeof(TCommand).Name, async ([FromBody] TCommand command, IModuleExecutor executor, CancellationToken cancellationToken) => + webKernel.App.MapPost("api/" + typeof(TModule).Name + "/" + typeof(TCommand).Name, async ([FromBody] TCommand command, IModuleExecutor executor, CancellationToken cancellationToken) => { var commandResult = await executor.Execute(command, cancellationToken); @@ -55,7 +55,7 @@ public static WebKernel MapCommand(this WebKe where TCommand : Command where TCommandResult : OperationResult { - webKernel.App.MapPost(typeof(TModule).Name + "/_commands/" + typeof(TCommand).Name, async ([FromBody] TCommand command, IModuleExecutor executor, CancellationToken cancellationToken) => + webKernel.App.MapPost("api/" + typeof(TModule).Name + "/" + typeof(TCommand).Name, async ([FromBody] TCommand command, IModuleExecutor executor, CancellationToken cancellationToken) => { var commandResult = await executor.Execute(command, cancellationToken);