MinimalApi.Endpoints
1.0.1
See the version list below for details.
dotnet add package MinimalApi.Endpoints --version 1.0.1
NuGet\Install-Package MinimalApi.Endpoints -Version 1.0.1
<PackageReference Include="MinimalApi.Endpoints" Version="1.0.1" />
paket add MinimalApi.Endpoints --version 1.0.1
#r "nuget: MinimalApi.Endpoints, 1.0.1"
// Install MinimalApi.Endpoints as a Cake Addin #addin nuget:?package=MinimalApi.Endpoints&version=1.0.1 // Install MinimalApi.Endpoints as a Cake Tool #tool nuget:?package=MinimalApi.Endpoints&version=1.0.1
MinimalApi.Endpoints
MinimalApi.Endpoints is a .NET Nuget package that allows you to easily structure your Minimal Api Endpoints in individual classes instead of having them all in Program.cs
.
Installation
You can install MinimalApi.Endpoints via NuGet Package Manager in Visual Studio or by using the following command in the Package Manager Console:
Install-Package MinimalApi.Endpoints
Usage
To use MinimalApi.Endpoints, simply call the MapEndpoints
extension method in your Program.cs
. Here's an example:
using MinimalApi;
var builder = WebApplication.CreateBuilder(args);
var app = builder.Build();
app.MapEndpoints();
app.Run();
Defining Endpoint Classes
To define an endpoint class, create a simple class that contains a method decorated with one of the following attributes to indicate the HTTP verb and route pattern for the endpoint:
EndpointGet
for GET requestsEndpointPost
for POST requestsEndpointPut
for PUT requests
Here's an example of how you can use the EndpointGet
attribute to create an endpoint that returns a list of users:
public class GetUsers
{
[EndpointGet("/users")]
public async Task<IEnumerable<User>> GetAsync(UserDb db)
{
return await db.Users.ToListAsync();
}
}
Here's an example of how you can use the EndpointGet
attribute to create an endpoint that returns a specific user:
public class GetUser
{
[EndpointGet("/users/{id}")]
public async Task<User> GetAsync(int id, UserDb db)
{
return await db.Users.FindAsync(id);
}
}
The method parameters can resolve to route/query/body values and registered services from the dependency container.
If you rather prefer to have all methods in one class:
public class WannaBeUserController
{
[EndpointGet("/users")]
public async Task<IEnumerable<User>> GetAllAsync(UserDb db)
{
return await db.Users.ToListAsync();
}
[EndpointGet("/users/{id}")]
public async Task<User> GetAsync(int id, UserDb db)
{
return await db.Users.FindAsync(id);
}
}
Limitations
- Only HTTP GET, POST, PUT methods are supported.
- PATCH and DELETE will be supported when .NET 8 is released.
License
MinimalApi.Endpoints is licensed under the MIT license. See the LICENSE file for more details.
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net6.0 is compatible. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 was computed. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. net9.0 was computed. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. |
-
net6.0
- No dependencies.
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
Version | Downloads | Last updated |
---|---|---|
1.3.6 | 0 | 2/19/2025 |
1.3.5 | 0 | 2/19/2025 |
1.3.4 | 52 | 2/18/2025 |
1.3.3 | 53 | 2/18/2025 |
1.3.2 | 57 | 2/18/2025 |
1.3.1 | 621 | 9/15/2023 |
1.3.0 | 176 | 8/30/2023 |
1.2.0 | 396 | 5/23/2023 |
1.1.0 | 317 | 5/8/2023 |
1.0.4 | 165 | 5/8/2023 |
1.0.3 | 180 | 5/8/2023 |
1.0.2 | 197 | 4/24/2023 |
1.0.1 | 177 | 4/24/2023 |
1.0.0 | 181 | 4/24/2023 |