Hyperbee.Pipeline.AspNetCore 3.0.0

dotnet add package Hyperbee.Pipeline.AspNetCore --version 3.0.0
                    
NuGet\Install-Package Hyperbee.Pipeline.AspNetCore -Version 3.0.0
                    
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="Hyperbee.Pipeline.AspNetCore" Version="3.0.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Hyperbee.Pipeline.AspNetCore" Version="3.0.0" />
                    
Directory.Packages.props
<PackageReference Include="Hyperbee.Pipeline.AspNetCore" />
                    
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 Hyperbee.Pipeline.AspNetCore --version 3.0.0
                    
#r "nuget: Hyperbee.Pipeline.AspNetCore, 3.0.0"
                    
#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 Hyperbee.Pipeline.AspNetCore@3.0.0
                    
#: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=Hyperbee.Pipeline.AspNetCore&version=3.0.0
                    
Install as a Cake Addin
#tool nuget:?package=Hyperbee.Pipeline.AspNetCore&version=3.0.0
                    
Install as a Cake Tool

Hyperbee.Pipeline.AspNetCore

The Hyperbee.Pipeline.AspNetCore library provides extensions that map CommandResult to ASP.NET Core HTTP responses using IResult.

Examples

Map Command Results to HTTP Responses

app.MapPost( "/items", async (
    CreateItemRequest request,
    ICommandFunction<CreateItemRequest, Item> command ) =>
{
    var commandResult = await command.ExecuteAsync( request );
    return commandResult.ToResult();
} );

Transform Results with a Content Selector

app.MapGet( "/items/{id}", async (
    Guid id,
    ICommandFunction<Guid, Item> command ) =>
{
    var commandResult = await command.ExecuteAsync( id );
    return commandResult.ToResult( item => new { item.Id, item.Name } );
} );

File Results

app.MapGet( "/reports/{id}", async (
    string id,
    ICommandFunction<string, Stream> command ) =>
{
    var commandResult = await command.ExecuteAsync( id );
    return commandResult.ToFileResult( "application/pdf" );
} );

Custom Result Mapping with ResultMapper

Subclass ResultMapper to customize error handling, status codes, and success responses. Override only the methods you need.

public class ConflictResultMapper : ResultMapper
{
    public override IResult? MapException( Exception exception ) => exception switch
    {
        WriteConflictRepositoryException => Results.Conflict( "Version mismatch. Reload and retry." ),
        CommandException { InnerException: WriteConflictRepositoryException }
            => Results.Conflict( "Version mismatch. Reload and retry." ),
        _ => base.MapException( exception )
    };
}

Register with DI and inject into endpoints:

services.AddSingleton<ResultMapper, ConflictResultMapper>();

app.MapPost( "/items", async (
    CreateItemRequest request,
    ICommandFunction<CreateItemRequest, Item> command,
    ResultMapper mapper ) =>
{
    var commandResult = await command.ExecuteAsync( request );
    return commandResult.ToResult( mapper );
} );

One-Off Mapper with Lambdas

Use ResultMapper.Create() for one-off customizations without subclassing:

var mapper = ResultMapper.Create(
    mapException: ex => ex is DbUpdateConcurrencyException
        ? Results.Conflict( "Version conflict." )
        : null
);

return commandResult.ToResult( x => x?.ToPresentation(), mapper );

Response Decorators

Chain .WithHeader() and .WithNoContent() to customize successful responses:

// Add an ETag header
return commandResult.ToResult( x => x?.ToPresentation(), mapper )
    .WithHeader( "ETag", commandResult.Result?.VersionTag );

// Return 204 No Content for write operations
return commandResult.ToResult( mapper ).WithNoContent();

Inline Result Mapping

Use a Func<CommandResult<T>, IResult?> for one-off custom handling. Return null to fall through to default handling.

var commandResult = await command.ExecuteAsync( request );
return commandResult.ToResult( cr =>
{
    if ( cr.Context.IsError && cr.Context.Exception is DbUpdateConcurrencyException )
        return Results.Conflict( "Version conflict. Reload and retry." );
    return null;
} );

Automatic Error Mapping

Validation failures are automatically converted to appropriate HTTP status codes with RFC 7807 Problem Details responses:

Failure Type HTTP Status
NotFoundValidationFailure 404 Not Found
UnauthorizedValidationFailure 401 Unauthorized
ForbiddenValidationFailure 403 Forbidden
ApplicationValidationFailure 422 Unprocessable Entity
ValidationFailure 422 Unprocessable Entity

Override GetStatusCode on your ResultMapper subclass to customize these mappings.

Target frameworks

net11.0, net10.0, net8.0. The FrameworkReference on Microsoft.AspNetCore.App rules out netstandard2.1, so a net8.0 or net9.0 project resolves the net8.0 asset; see the repository README.

Product Compatible and additional computed target framework versions.
.NET net8.0 is compatible.  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.  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.  net11.0 is compatible. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

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
3.0.0 51 11/28/2026
2.16.1 61 11/26/2026
2.16.0 62 11/26/2026
2.15.0 3,228 7/15/2026
2.14.0 2,176 6/8/2026
2.13.0 866 5/19/2026
2.12.0 1,196 4/12/2026
2.11.1 1,913 3/26/2026
2.10.1-alpha-gc6f6d9837f 135 3/25/2026
2.9.1 2,036 3/19/2026
2.9.0 141 3/19/2026
2.8.2 173 3/16/2026
2.7.0 819 2/28/2026
2.6.0 154 2/28/2026
2.5.0 163 2/28/2026
2.4.0 165 2/27/2026
2.3.3 4,350 2/24/2026
2.3.2 518 2/18/2026
2.3.1 156 2/18/2026
2.3.0 148 2/17/2026