The goal of this project it's to show how to use MinimalApi.Endpoint package.
It demontrate how to configure API endpoints as individual classes based on minimal Api (.Net 6)
Use AddEndpoints extenion method to create each endpoint.
And also MapEndpoint extension method to use new routing APIs
var builder = WebApplication.CreateBuilder(args);
builder.Services.AddEndpoints();
var app = builder.Build();
app.MapEndpoints();
app.Run();
To create and define one endpoint, it needs to implement IEndpoint interface
public class GetWithParamEndpoint : IEndpoint<string, string>
{
public void AddRoute(IEndpointRouteBuilder app)
{
app.MapGet("/Todo/2/{param1}", (string param1) => HandleAsync(param1));
}
public Task<string> HandleAsync(string request)
{
return Task.FromResult($"Hello World! 2 {request}");
}
}
-
eShopOnWeb: Sample ASP.NET Core reference application, powered by Microsoft
- Use in PublicApi project: This project demonstrates how to configure endpoints as individual classes
-
EshopOnVue.js: Same as EshopOnWeb project in Vue.js
-
StructuredMinimalApi: Sample project to show some usage
-
WebApiBestPractices: Resources related to Ardalis Pluralsight course on this topic.
- Pluralsight : ASP.NET Core 6 Web API: Best Practices: Organizing Minimal API demo and best practices.
A nuget package is available here.