Captain.Hookz
10.0.0
dotnet add package Captain.Hookz --version 10.0.0
NuGet\Install-Package Captain.Hookz -Version 10.0.0
<PackageReference Include="Captain.Hookz" Version="10.0.0" />
<PackageVersion Include="Captain.Hookz" Version="10.0.0" />
<PackageReference Include="Captain.Hookz" />
paket add Captain.Hookz --version 10.0.0
#r "nuget: Captain.Hookz, 10.0.0"
#:package Captain.Hookz@10.0.0
#addin nuget:?package=Captain.Hookz&version=10.0.0
#tool nuget:?package=Captain.Hookz&version=10.0.0
✨ What is Hookz?
Hookz.Http adds composable lifecycle hooks (WithBefore, WithAfter, WithError) to your ASP.NET Minimal API endpoints.
It’s like middleware—but scoped, fluent, and inline.
Hookz.Http 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 | 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
- 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.