Alvecta.Foundation.Presentation.WebApi.AspNetCore
6.3.63
See the version list below for details.
dotnet add package Alvecta.Foundation.Presentation.WebApi.AspNetCore --version 6.3.63
NuGet\Install-Package Alvecta.Foundation.Presentation.WebApi.AspNetCore -Version 6.3.63
<PackageReference Include="Alvecta.Foundation.Presentation.WebApi.AspNetCore" Version="6.3.63" />
<PackageVersion Include="Alvecta.Foundation.Presentation.WebApi.AspNetCore" Version="6.3.63" />
<PackageReference Include="Alvecta.Foundation.Presentation.WebApi.AspNetCore" />
paket add Alvecta.Foundation.Presentation.WebApi.AspNetCore --version 6.3.63
#r "nuget: Alvecta.Foundation.Presentation.WebApi.AspNetCore, 6.3.63"
#:package Alvecta.Foundation.Presentation.WebApi.AspNetCore@6.3.63
#addin nuget:?package=Alvecta.Foundation.Presentation.WebApi.AspNetCore&version=6.3.63
#tool nuget:?package=Alvecta.Foundation.Presentation.WebApi.AspNetCore&version=6.3.63
Alvecta.Foundation.Presentation.WebApi.AspNetCore
Maps Alvecta use cases (Alvecta.Foundation.Application.Contracts) as ASP.NET Core minimal-API
endpoints, one line per use case, and adds a /version endpoint. Formerly
Alvecta.Foundation.Api.AspNetCore.
It belongs to the Presentation layer: an inbound (driving) adapter that calls use-case
interfaces and never sees their implementations. Dependencies: the Microsoft.AspNetCore.App
shared framework, Alvecta.Utils, Alvecta.Utils.UserExceptions and
Alvecta.Foundation.Application.Contracts.
What it contains
Extension methods on IEndpointRouteBuilder:
| Method | Use case | Endpoint |
|---|---|---|
MapUseCase<TUseCase>() |
IUseCase |
POST, no body, no result |
MapUseCase<TUseCase, TRequest>() |
IUseCase<TRequest> |
POST, JSON body, no result |
MapUseCase<TUseCase, TRequest, TResponse>() |
IUseCase<TRequest, TResponse> |
POST, JSON body, JSON result |
MapUseCaseWithoutRequest<TUseCase, TResponse>() |
IUseCaseWithoutRequest<TResponse> |
POST, no body, JSON result |
MapVersionEndpoint() |
— | GET /version, anonymous, the entry assembly's informational version as text |
- Routes come from the interface name. The leading
Iand the trailingUseCaseare removed:IGetOrderUseCasemaps toGetOrder, relative to the route group.TUseCasemust be an interface named that way, otherwise mapping throws at startup. - Every use case is a
POST. The use case is resolved from DI per request. - Requests are validated first. When a request implements
IValidatable(Alvecta.Utils.Validation), itsValidate()runs before the use case, and any errors are thrown as aUserException. - Each method returns the
RouteHandlerBuilder, so authorization, filters and metadata chain on as usual.
Usage
dotnet add package Alvecta.Foundation.Presentation.WebApi.AspNetCore
using Alvecta.Foundation.Application.Contracts.Database;
using Alvecta.Foundation.Presentation.WebApi.AspNetCore;
var app = builder.Build();
app.MapVersionEndpoint();
var orders = app.MapGroup("/api/orders").RequireAuthorization();
orders.MapUseCase<IGetOrderUseCase, IGetOrderUseCase.Request, IGetOrderUseCase.Response>(); // POST /api/orders/GetOrder
orders.MapUseCase<ICancelOrderUseCase, ICancelOrderUseCase.Request>(); // POST /api/orders/CancelOrder
var database = app.MapGroup("/api/database").RequireAuthorization("ApiKeyPolicy");
database.MapUseCase<IMigrateDatabaseUseCase>(); // POST /api/database/MigrateDatabase
app.Run();
Turning a UserException into an HTTP response is up to the host, for example with the
UserExceptionHandlingMiddleware from Alvecta.Utils.AspNetCore.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net10.0 is compatible. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
-
net10.0
- Alvecta.Foundation.Application.Contracts (>= 6.3.63)
- Alvecta.Utils (>= 8.0.66)
- Alvecta.Utils.UserExceptions (>= 8.0.66)
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 |
|---|---|---|
| 7.0.73 | 42 | 10/23/2026 |
| 7.0.72 | 47 | 10/23/2026 |
| 7.0.71 | 50 | 10/23/2026 |
| 7.0.70 | 47 | 10/22/2026 |
| 7.0.69 | 49 | 10/21/2026 |
| 7.0.68 | 42 | 10/21/2026 |
| 7.0.67 | 52 | 10/20/2026 |
| 7.0.66 | 62 | 10/19/2026 |
| 7.0.65 | 76 | 10/19/2026 |
| 6.3.64 | 83 | 10/19/2026 |
| 6.3.63 | 77 | 10/19/2026 |
| 6.2.62 | 88 | 10/14/2026 |
| 6.1.61 | 95 | 10/9/2026 |
| 6.1.60 | 85 | 10/7/2026 |
| 6.1.59 | 95 | 10/6/2026 |
| 6.1.58 | 92 | 10/5/2026 |
| 6.0.57 | 98 | 10/2/2026 |
| 6.0.56 | 101 | 10/1/2026 |
| 6.0.55 | 90 | 10/1/2026 |
| 5.0.54 | 103 | 9/30/2026 |