Lewee.Infrastructure.FastEndpoints 0.40.3

dotnet add package Lewee.Infrastructure.FastEndpoints --version 0.40.3
                    
NuGet\Install-Package Lewee.Infrastructure.FastEndpoints -Version 0.40.3
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Lewee.Infrastructure.FastEndpoints" Version="0.40.3" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Lewee.Infrastructure.FastEndpoints" Version="0.40.3" />
                    
Directory.Packages.props
<PackageReference Include="Lewee.Infrastructure.FastEndpoints" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add Lewee.Infrastructure.FastEndpoints --version 0.40.3
                    
#r "nuget: Lewee.Infrastructure.FastEndpoints, 0.40.3"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package Lewee.Infrastructure.FastEndpoints@0.40.3
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=Lewee.Infrastructure.FastEndpoints&version=0.40.3
                    
Install as a Cake Addin
#tool nuget:?package=Lewee.Infrastructure.FastEndpoints&version=0.40.3
                    
Install as a Cake Tool

Lewee.Infrastructure.FastEndpoints

FastEndpoints base classes for building Web API endpoints with MediatR integration and correlation ID support.

Purpose

This package provides abstract base classes for building FastEndpoints-based Web API endpoints that integrate with the CQRS pattern implemented in Lewee.Application. It simplifies endpoint creation by providing common functionality for command and query handling, result mapping, and correlation ID propagation.

Dependencies

Components

CommandEndpoint<TRequest>

Abstract base class for endpoints that handle commands (POST, PUT, PATCH, DELETE operations):

public class CreateOrderEndpoint : CommandEndpoint<CreateOrderRequest>
{
    protected override string Route => "/orders";
    protected override string Name => "CreateOrder";
    protected override CommandType CommandType => CommandType.Post;
    protected override bool IsAnonymousAllowed => false;

    public override async Task HandleAsync(CreateOrderRequest req, CancellationToken ct)
    {
        var command = new CreateOrderCommand(this.CorrelationId, req.CustomerId, req.Items);
        var result = await this.Mediator.Send(command, ct);
        await this.ToResponseAsync(result, ct);
    }
}

Abstract Properties:

Property Type Description
Route string The endpoint route
Name string The endpoint name for OpenAPI
CommandType CommandType HTTP method (Post, Put, Patch, Delete)
IsAnonymousAllowed bool Whether anonymous access is allowed

Protected Members:

Member Type Description
Mediator IMediator MediatR mediator instance
CorrelationId Guid Current request correlation ID

QueryEndpoint<T>

Abstract base class for endpoints that handle queries (GET operations):

public class GetOrdersEndpoint : QueryEndpoint<OrderDto[]>
{
    protected override string Route => "/orders";
    protected override string Name => "GetOrders";
    protected override bool IsAnonymousAllowed => false;

    public override async Task HandleAsync(CancellationToken ct)
    {
        var query = new GetOrdersQuery(this.CorrelationId);
        var result = await this.Mediator.Send(query, ct);
        await this.ToResponseAsync(result, ct);
    }
}

Abstract Properties:

Property Type Description
Route string The endpoint route
Name string The endpoint name for OpenAPI
IsAnonymousAllowed bool Whether anonymous access is allowed

CommandType

Enum for specifying the HTTP method of command endpoints:

Value HTTP Method
Post POST
Put PUT
Patch PATCH
Delete DELETE

Result Handling

Both endpoint base classes provide ToResponseAsync methods that map Lewee.Application result types to HTTP responses:

Result Status HTTP Response
Success 200 OK
NotFound 404 Not Found
ValidationError 400 Bad Request
DomainError 400 Bad Request
Unauthenticated 401 Unauthorized
Forbidden 403 Forbidden
Conflict 409 Conflict
UnexpectedError 500 Internal Server Error

CorrelationContextAccessorExtensions

Internal extension method to get correlation ID from ICorrelationContextAccessor, generating a new GUID if not present.

Sample Usage

See the Pizzeria Store API project for complete implementation examples of command and query endpoints.

Product Compatible and additional computed target framework versions.
.NET net11.0 is compatible. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages (1)

Showing the top 1 NuGet packages that depend on Lewee.Infrastructure.FastEndpoints:

Package Downloads
Lewee.Auth.Api

Package Description

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
0.40.3 44 11/22/2026