-
Notifications
You must be signed in to change notification settings - Fork 1.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Minimal API Support #653
Comments
That would be very cool, but my opinion is that it should be in the form of an extension nuget package, maybe? |
Yeah something like I would love to get cracking with this just not sure what repository it would live under? |
I started to put together a project to scope this out you can see it here https://github.com/mumby0168/blog-samples/tree/main/new-features/MinimalApis While doing so I came across a current limitation of the minimal API's I have logged in issue about it here: dotnet/aspnetcore#35304 |
@jbogard what do you think about this? They have recently added a more flexible way to allow custom parameters to be bound. See the previous comment with a link to the issue. |
@mumby0168 This is what I have developed in https://github.com/Kahbazi/MediatR.AspNetCore.Endpoints You can register public class Startup
{
public void ConfigureServices(IServiceCollection services)
{
services.AddMediatR(GetType().Assembly);
services.AddMediatREndpoints();
}
public void Configure(IApplicationBuilder app)
{
app.UseRouting();
app.UseEndpoints(endpoints =>
{
endpoints.MapMediatR();
});
}
} |
Ah that is really cool, how do you handle mapping query params to an object? |
Yeah that us pretty cool. And how would you apply security requirements, on the IRequest with a custom filter ? |
I haven't implement that yet.
You can apply |
I try to do something similar, with extension methods that allow to map a route to a an IRequest. Something like that app.MediatR().MapGet("/hello", (string name) => new HelloQuery(name)); Which will be the equivalent of app.MapGet("/hello", (string name, IMediator mediator, CancellationToken token) =>
mediator.Send(new HelloQuery(name), token)
); The idea is to have something similar as the original API, with less boilerplate. The problem is that I don't know the correct approach to use... I tried to create a dynamic delegate that wrap the original one and that adds the mediator and the token, but I don't think it is a good approach, and I have a lack of knowledge in this domain so I struggled with lot of problems. Maybe the most simple solution is to have a middleware that handles the IRequest, but with this solution, I don't know how Swagger will know the actual return type of the method. I will try to dig a bit. |
@srollinet did you make any progress? |
@vip32 No, I haven't done anything. And I will probably wait for asp.net core 7 because the new https://devblogs.microsoft.com/dotnet/asp-net-core-updates-in-dotnet-7-preview-5/ |
Seeing the recent advancements on the minimal APIs within ASP.NET Core.
It would be really cool if we could look at some extension methods that sit on top of this and provide a way to map
IRequest<T>
handlers directly to http routes without having to use a controller.I expect this would be a set of extension methods.
The text was updated successfully, but these errors were encountered: