Captain.Hookz
1.0.5
dotnet add package Captain.Hookz --version 1.0.5
NuGet\Install-Package Captain.Hookz -Version 1.0.5
<PackageReference Include="Captain.Hookz" Version="1.0.5" />
<PackageVersion Include="Captain.Hookz" Version="1.0.5" />
<PackageReference Include="Captain.Hookz" />
paket add Captain.Hookz --version 1.0.5
#r "nuget: Captain.Hookz, 1.0.5"
#addin nuget:?package=Captain.Hookz&version=1.0.5
#tool nuget:?package=Captain.Hookz&version=1.0.5
✨ 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 | Versions 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. |
-
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.
1.0.5 has dropped! This is the initial MVP, more features will follow!