Knight.Response.Abstractions.Http
2.0.0-preview02
See the version list below for details.
dotnet add package Knight.Response.Abstractions.Http --version 2.0.0-preview02
NuGet\Install-Package Knight.Response.Abstractions.Http -Version 2.0.0-preview02
<PackageReference Include="Knight.Response.Abstractions.Http" Version="2.0.0-preview02" />
<PackageVersion Include="Knight.Response.Abstractions.Http" Version="2.0.0-preview02" />
<PackageReference Include="Knight.Response.Abstractions.Http" />
paket add Knight.Response.Abstractions.Http --version 2.0.0-preview02
#r "nuget: Knight.Response.Abstractions.Http, 2.0.0-preview02"
#:package Knight.Response.Abstractions.Http@2.0.0-preview02
#addin nuget:?package=Knight.Response.Abstractions.Http&version=2.0.0-preview02&prerelease
#tool nuget:?package=Knight.Response.Abstractions.Http&version=2.0.0-preview02&prerelease
Knight.Response.Abstractions.Http
Cross‑framework abstractions for HTTP result handling in the Knight.Response family.
This package collects the shared contracts, options, and resolvers that both
Knight.Response.AspNetCore
(for modern ASP.NET Core / minimal APIs), andKnight.Response.AspNetCore.Mvc
(for legacy ASP.NET Core MVC 2.x / .NET Framework scenarios)
use to keep behavior consistent.
Target frameworks: .NET Standard 2.0 (works with .NET Framework 4.7.1+ and .NET Core/.NET 6+).
What’s inside
KnightResponseBaseOptions<TH, TProblem, TValidation>
Base options class that centralizes:UseProblemDetails
(default:false
)UseValidationProblemDetails
(default:false
)IncludeFullResultPayload
(default:false
, wastrue
before 2.0.0-preview01)IncludeExceptionDetails
(default:false
)CodeToHttp
delegate (optional, domain codes → HTTP codes)StatusCodeResolver
delegate (defaults to 400/409/500/200)- Optional builders/hooks for shaping problem responses
The generic parameters let each integration plug in the framework’s own HttpContext type (
TH
),ProblemDetails
type (TProblem
), andValidationProblemDetails
type (TValidation
) without duplication.HTTP mapping defaults and resolvers
KnightResponseHttpDefaults
— default mapping fromStatus
to HTTP codes.ResultHttpResolver
— unified logic for resolving an HTTP code from aResult
, honoringCodeToHttp
first and falling back toStatusCodeResolver
.
Validation error mapping
IValidationErrorMapper
— abstraction for converting domainMessage
s into aDictionary<string,string[]>
suitable for validation problems.DefaultValidationErrorMapper
— conservative default implementation.- Consumers can register their own mapper in DI. If none is provided, integrations will fall back to the default.
Install
dotnet add package Knight.Response.Abstractions.Http
You typically won’t reference this directly in application code; it’s a transitive dependency of the ASP.NET/MVC integration packages. It’s useful if you’re building your own integration and want to align with Knight.Response conventions.
Quick examples
Custom validation mapper
using Knight.Response.Abstractions.Http.Mappers;
public sealed class MyValidationMapper : IValidationErrorMapper
{
public IDictionary<string, string[]> Map(IReadOnlyList<Message> messages)
=> new Dictionary<string, string[]> { ["name"] = new[] { "is required" } };
}
Register this type in the DI container of your chosen integration package
(e.g., Knight.Response.AspNetCore
or Knight.Response.Mvc
).
Custom HTTP code mapping
using Knight.Response.Models;
using Knight.Response.Abstractions.Http.Options;
services.AddKnightResponse(opts =>
{
opts.CodeToHttp = code => code?.Value switch
{
var v when v == ResultCodes.NotFound.Value => 404,
var v when v == ResultCodes.AlreadyExists.Value => 409,
_ => null
};
});
Related packages
Knight.Response
— immutableResult
/Result<T>
core library.Knight.Response.AspNetCore
— modern ASP.NET Core + minimal APIs integration.Knight.Response.AspNetCore.Mvc
— ASP.NET Core MVC 2.x / .NET Framework–friendly integration.
License
This project is licensed under the MIT License.
Contributing
Contributions are welcome! Please read CONTRIBUTING.md.
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net5.0 was computed. net5.0-windows was computed. net6.0 was computed. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 was computed. 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. |
.NET Core | netcoreapp2.0 was computed. netcoreapp2.1 was computed. netcoreapp2.2 was computed. netcoreapp3.0 was computed. netcoreapp3.1 was computed. |
.NET Standard | netstandard2.0 is compatible. netstandard2.1 was computed. |
.NET Framework | net461 was computed. net462 was computed. net463 was computed. net47 was computed. net471 was computed. net472 was computed. net48 was computed. net481 was computed. |
MonoAndroid | monoandroid was computed. |
MonoMac | monomac was computed. |
MonoTouch | monotouch was computed. |
Tizen | tizen40 was computed. tizen60 was computed. |
Xamarin.iOS | xamarinios was computed. |
Xamarin.Mac | xamarinmac was computed. |
Xamarin.TVOS | xamarintvos was computed. |
Xamarin.WatchOS | xamarinwatchos was computed. |
-
.NETStandard 2.0
- Knight.Response (>= 2.0.0-preview04)
NuGet packages (2)
Showing the top 2 NuGet packages that depend on Knight.Response.Abstractions.Http:
Package | Downloads |
---|---|
Knight.Response.Mvc
ASP.NET MVC / Web API 2 adapters for Knight.Response — convert Result/Result<T> to IActionResult/IHttpActionResult with optional RFC7807 ProblemDetails. |
|
Knight.Response.AspNetCore
ASP.NET Core helpers for Knight.Response: map Result/Result<T> to IResult/ActionResult with consistent HTTP semantics. |
GitHub repositories
This package is not used by any popular GitHub repositories.
Version | Downloads | Last Updated |
---|---|---|
2.0.0-preview03 | 138 | 9/27/2025 |
2.0.0-preview02 | 223 | 9/25/2025 |
2.0.0-preview01 | 318 | 9/24/2025 |
1.0.2 | 511 | 9/1/2025 |
1.0.1 | 262 | 8/28/2025 |
1.0.0 | 182 | 8/28/2025 |
- Added ResultHttpResolver with unified CodeToHttp/Status fallback.
- Introduced KnightResponseHttpDefaults with Status→HTTP defaults.
- CodeToHttp delegate now optional and consumer-configurable.