VOOZH about

URL: https://www.nuget.org/packages/PANiXiDA.Core.Presentation.Http/

⇱ NuGet Gallery | PANiXiDA.Core.Presentation.Http 2.0.3-preview




👁 Image
PANiXiDA.Core.Presentation.Http 2.0.3-preview

This is a prerelease version of PANiXiDA.Core.Presentation.Http.
dotnet add package PANiXiDA.Core.Presentation.Http --version 2.0.3-preview
 
 
NuGet\Install-Package PANiXiDA.Core.Presentation.Http -Version 2.0.3-preview
 
 
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="PANiXiDA.Core.Presentation.Http" Version="2.0.3-preview" />
 
 
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="PANiXiDA.Core.Presentation.Http" Version="2.0.3-preview" />
 
Directory.Packages.props
<PackageReference Include="PANiXiDA.Core.Presentation.Http" />
 
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 PANiXiDA.Core.Presentation.Http --version 2.0.3-preview
 
 
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: PANiXiDA.Core.Presentation.Http, 2.0.3-preview"
 
 
#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.
#:package PANiXiDA.Core.Presentation.Http@2.0.3-preview
 
 
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=PANiXiDA.Core.Presentation.Http&version=2.0.3-preview&prerelease
 
Install as a Cake Addin
#tool nuget:?package=PANiXiDA.Core.Presentation.Http&version=2.0.3-preview&prerelease
 
Install as a Cake Tool
The NuGet Team does not provide support for this client. Please contact its maintainers for support.

PANiXiDA.Core.Presentation.Http

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.

Status

👁 CI
👁 NuGet
👁 NuGet downloads
👁 Target Framework

Features

  • AddHttp registers the default HTTP presentation services.
  • UseHttp adds the default middleware pipeline and maps discovered endpoint groups.
  • Health checks are registered by 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.

Requirements

  • .NET 10 SDK.
  • ASP.NET Core Minimal API application.

Installation

<ItemGroup>
 <PackageReference Include="PANiXiDA.Core.Presentation.Http" Version="2.0.0-preview" />
</ItemGroup>

Quick Start

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);

Forwarded Headers

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"));
});

Health Checks

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());

Endpoint Groups

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.

Endpoints

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);

Result Mapping

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();
}

HTTP Error Mapping

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.

OpenAPI

In Development, UseHttp exposes:

  • OpenAPI document at /openapi/v1.json;
  • Scalar API reference at /scalar.

OpenAPI registration also enables Scalar transformers for Scalar-specific document extensions.

OpenAPI is not mapped automatically outside Development.

API Versioning

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.

Project Structure

src/
 PANiXiDA.Core.Presentation.Http/
 Configurations/
 DependencyInjection/
 Endpoints/
 Helpers/
 Middlewares/
tests/
 PANiXiDA.Core.Presentation.Http.UnitTests/

Development

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.

Package Contents

The NuGet package includes:

  • compiled library for net10.0;
  • XML documentation;
  • README;
  • package icon;
  • Source Link metadata;
  • symbols package when packed with repository settings.

License

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. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

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
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