![]() |
VOOZH | about |
dotnet add package PANiXiDA.Core.Presentation.Http --version 2.0.3-preview
NuGet\Install-Package PANiXiDA.Core.Presentation.Http -Version 2.0.3-preview
<PackageReference Include="PANiXiDA.Core.Presentation.Http" Version="2.0.3-preview" />
<PackageVersion Include="PANiXiDA.Core.Presentation.Http" Version="2.0.3-preview" />Directory.Packages.props
<PackageReference Include="PANiXiDA.Core.Presentation.Http" />Project file
paket add PANiXiDA.Core.Presentation.Http --version 2.0.3-preview
#r "nuget: PANiXiDA.Core.Presentation.Http, 2.0.3-preview"
#:package PANiXiDA.Core.Presentation.Http@2.0.3-preview
#addin nuget:?package=PANiXiDA.Core.Presentation.Http&version=2.0.3-preview&prereleaseInstall as a Cake Addin
#tool nuget:?package=PANiXiDA.Core.Presentation.Http&version=2.0.3-preview&prereleaseInstall as a Cake Tool
PANiXiDA.Core.Presentation.Http is a reusable ASP.NET Core HTTP presentation package for PANiXiDA applications.
It provides common Minimal API endpoint conventions, API versioning, OpenAPI setup, Problem Details handling, health checks, request logging, exception handling, forwarded headers configuration, and helpers for mapping PANiXiDA.Core.ResultPattern results to HTTP responses.
👁 CI
👁 NuGet
👁 NuGet downloads
👁 Target Framework
AddHttp registers the default HTTP presentation services.UseHttp adds the default middleware pipeline and maps discovered endpoint groups.AddHttp and exposed at /health by UseHttp.IEndpointGroup defines route, resource name, and API version metadata for Minimal API endpoint groups.IEndpoint<TGroup> defines route, name, and summary metadata for endpoints that belong to a specific group.EndpointMapper discovers and maps endpoints in a deterministic type-name order.EndpointConstants.EndpointPrefix defines /api/v{version:apiVersion}.ResultHttpMapper maps Result and Result<T> to IResult.<ItemGroup>
<PackageReference Include="PANiXiDA.Core.Presentation.Http" Version="2.0.0-preview" />
</ItemGroup>
using PANiXiDA.Core.Presentation.Http.DependencyInjection;
var builder = WebApplication.CreateBuilder(args);
builder.Services.AddHttp(builder.Configuration);
var app = builder.Build();
app.UseHttp(typeof(Program).Assembly);
app.Run();
Pass null to AddHttp if forwarded headers should use the package defaults.
builder.Services.AddHttp(configuration: null);
The package configures these forwarded headers by default:
ForwardedHeaders.XForwardedFor |
ForwardedHeaders.XForwardedHost |
ForwardedHeaders.XForwardedProto
The package also clears the default loopback-only KnownIPNetworks and KnownProxies restrictions so applications behind Kubernetes ingress or Gateway API proxies can process forwarded headers without per-service proxy registration.
Additional values can be bound from the standard ASP.NET Core ForwardedHeadersOptions model by adding a ForwardedHeaders section to the application configuration.
{
"ForwardedHeaders": {
"ForwardedHeaders": "XForwardedFor, XForwardedHost, XForwardedProto",
"ForwardLimit": 2,
"RequireHeaderSymmetry": true,
"AllowedHosts": [
"api.example.com"
]
}
}
For stricter trust boundaries, configure ForwardedHeadersOptions directly after AddHttp.
using Microsoft.AspNetCore.HttpOverrides;
using System.Net;
builder.Services.AddHttp(builder.Configuration);
builder.Services.Configure<ForwardedHeadersOptions>(options =>
{
options.KnownProxies.Add(IPAddress.Parse("10.0.0.10"));
});
AddHttp registers ASP.NET Core health check services, and UseHttp maps the health check endpoint at /health.
GET /health
Services can add their own checks after AddHttp.
using Microsoft.Extensions.Diagnostics.HealthChecks;
builder.Services.AddHealthChecks()
.AddCheck("self", () => HealthCheckResult.Healthy());
An endpoint group owns a route prefix, resource name, API version, and the call to map endpoints that belong to the group.
using Asp.Versioning;
using Microsoft.AspNetCore.Routing;
using PANiXiDA.Core.Presentation.Http.Endpoints;
public sealed class OrdersEndpointGroup : IEndpointGroup
{
public string Route { get; } = "/orders";
public string Name { get; } = "Orders";
public ApiVersion ApiVersion { get; } = new(1, 0);
public void Map(IEndpointRouteBuilder endpoints)
{
EndpointMapper.MapGroupEndpoints<OrdersEndpointGroup>(endpoints);
}
}
The final route prefix is /api/v{version}/orders.
An endpoint implements IEndpoint<TGroup>, where TGroup is the endpoint group it belongs to.
Endpoint metadata is declared as public properties so it can be required by the interface and applied by EndpointMapper.
using Microsoft.AspNetCore.Http;
using PANiXiDA.Core.Presentation.Http.Endpoints;
public sealed class GetOrderEndpoint : IEndpoint<OrdersEndpointGroup>
{
public string Route { get; } = "/{id:guid}";
public string Name { get; } = "GetOrder";
public string Summary { get; } = "Gets an order by identifier.";
public void Map(EndpointMapBuilder builder)
{
builder.MapGet((Guid id) =>
{
return TypedResults.Ok(new OrderResponse(id));
});
}
}
public sealed record OrderResponse(Guid Id);
Successful results are mapped through the provided success factory.
using Microsoft.AspNetCore.Http;
using PANiXiDA.Core.Presentation.Http.Helpers;
using PANiXiDA.Core.ResultPattern;
public static IResult GetOrder(Guid id)
{
Result<OrderResponse> result = Result.Success(new OrderResponse(id));
return result.ToHttpResult(value =>
{
return TypedResults.Ok(value);
});
}
Failed results are mapped to ProblemDetails or ValidationProblem.
using Microsoft.AspNetCore.Http;
using PANiXiDA.Core.Presentation.Http.Helpers;
using PANiXiDA.Core.ResultPattern;
public static IResult CreateOrder()
{
Result result = Result.Failure(Error.Validation("Email is required").WithField("Email"));
return result.ToHttpProblem();
}
Unhandled exceptions are mapped to ProblemDetails in every environment.
In Development, the response includes the exception message in detail.
| Error type | HTTP status | Title |
|---|---|---|
Validation |
400 | One or more validation errors occurred. |
NotFound |
404 | Resource not found |
Conflict |
409 | Conflict |
Unauthorized |
401 | Unauthorized |
Forbidden |
403 | Forbidden |
Failure |
400 | Request failed |
Unexpected |
500 | Server error |
Validation error fields are used as ValidationProblem keys. If a validation error has no field, the key is general.
In Development, UseHttp exposes:
/openapi/v1.json;/scalar.OpenAPI registration also enables Scalar transformers for Scalar-specific document extensions.
OpenAPI is not mapped automatically outside Development.
The package configures URL segment API versioning:
/api/v1/orders
The default API version is 1.0, and the version must be present in the route.
src/
PANiXiDA.Core.Presentation.Http/
Configurations/
DependencyInjection/
Endpoints/
Helpers/
Middlewares/
tests/
PANiXiDA.Core.Presentation.Http.UnitTests/
Run the standard validation before publishing:
dotnet restore
dotnet format
dotnet build --configuration Release
dotnet test --configuration Release
dotnet pack --configuration Release
Run coverage:
dotnet test --configuration Release -- --coverage --coverage-output coverage.xml --coverage-output-format xml
The source files under src/PANiXiDA.Core.Presentation.Http are covered by unit tests. Coverage excludes generated files under obj/ from ASP.NET Core and validation source generators.
The NuGet package includes:
net10.0;This project is licensed under the Apache-2.0 license. See for details.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net10.0 net10.0 is compatible. net10.0-android net10.0-android was computed. net10.0-browser net10.0-browser was computed. net10.0-ios net10.0-ios was computed. net10.0-maccatalyst net10.0-maccatalyst was computed. net10.0-macos net10.0-macos was computed. net10.0-tvos net10.0-tvos was computed. net10.0-windows net10.0-windows was computed. |
This package is not used by any NuGet packages.
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 2.0.3-preview | 0 | 6/18/2026 |
| 2.0.2-preview | 64 | 6/14/2026 |
| 2.0.1-preview | 61 | 6/13/2026 |
| 1.0.3-preview | 51 | 6/12/2026 |
| 1.0.2-preview | 59 | 5/21/2026 |