Captain.Hookz 1.0.5

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

hookz3

✨ What is Hookz?

Hookz adds composable lifecycle hooks (WithBefore, WithAfter, WithError) to your ASP.NET Minimal API endpoints.
It’s like middleware—but scoped, fluent, and inline.

Hookz helps you:

  • Short-circuit requests

  • Inject logging, metrics, and headers

  • Clean up and finalize logic after execution

  • Chain multiple hooks per route

  • 📦 Install

dotnet add package Captain.Hookz

Supports .NET 8, and .NET 9

🚀 Usage Examples

📤 Modify response headers

app.MapGet("/data", () => Results.Ok("Payload"))
   .WithAfter(ctx =>
   {
       ctx.Response.Headers.Append("X-Processed", "true");
   });

🧠 Inject and call other services

app.MapPost("/log", () => Results.Ok("Logged"))
   .WithAfter<ILogger<Program>>(async (ctx, logger) =>
   {
	   await Task.Delay(500);
	   logger.LogInformation("POST /log handled.");
   });

🔁 Chain multiple hooks

app.MapGet("/multi", () => Results.Ok("Chained"))
   .WithBefore(ctx => Console.WriteLine("Before 1"))
   .WithBefore(ctx => Console.WriteLine("Before 2"))
   .WithAfter(ctx => Console.WriteLine("After"));

🧪 Unit-Test Friendly Hookz runs cleanly in WebApplicationFactory and supports mocking HttpContext to verify DI behavior or request filtering.

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 was computed.  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. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
  • net8.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.0.5 131 5/11/2025
1.0.4 124 5/11/2025
1.0.3 121 5/10/2025
1.0.2 59 5/10/2025

1.0.5 has dropped! This is the initial MVP, more features will follow!