zentient results api reference Integration Points - ulfbou/Zentient.Results GitHub Wiki

๐ŸŒ ASP.NET Core Integration

Namespace: Zentient.Results Assembly: Zentient.Results.dll Available since: v0.3.0


๐Ÿ“– Summary

Zentient.Results integrates seamlessly into ASP.NET Core applications by enabling structured and protocol-neutral handling of operation outcomes through IResult and IResult<T>. These abstractions allow for consistent error propagation, diagnostics, and status mapping, independent of transport protocols.

While manual integration works today, official support for HTTP-based pipelines is being developed in the pre-release library Zentient.Endpoints.Http (part of the upcoming Zentient.Endpoints module suite).


๐Ÿ”ง Manual Integration Patterns

Until the release of full HTTP adapters, developers can implement lightweight bridges between IResult and IActionResult.

โœ… Minimal API Example

app.MapPost("/users", async (UserDto dto, IUserService service) =>
{
    IResult<User> result = await service.CreateUserAsync(dto);

    return result.IsSuccess
        ? Results.Ok(result.Value)
        : Results.Problem(result.ToProblemDetails());
});

โœ… Controller Example

[HttpGet("{id}")]
public IActionResult GetUser(Guid id)
{
    var result = _service.GetById(id);

    if (result.IsSuccess)
        return Ok(result.Value);

    return StatusCode(result.Status.Code, result.ToProblemDetails());
}

๐Ÿงญ Pre-release Integration Libraries

The following libraries are in active development and will provide drop-in support for ASP.NET Core:

Library Purpose
Zentient.Endpoints.Http Adapter and conversion layer for IResult โ†’ IActionResult, full ProblemDetails compliance, HTTP status code mapping, and error serialization.
Zentient.Endpoints.Core Shared abstractions and pipelines for mapping results across transport protocols.
Zentient.Telemetry Extension points for enriching and observing results via logging, tracing, and diagnostics.

These modules will be incrementally published starting from v0.5.0 as part of the Zentient.Endpoints roadmap.


๐Ÿงช Usage Tips

1. Use ToProblemDetails() for Failures

return Results.Problem(result.ToProblemDetails());

This method creates a standards-compliant problem document (based on RFC 9457) using data from ErrorInfo.

2. Return Semantic Status Codes

return StatusCode(result.Status.Code, result.ToProblemDetails());

Respects the semantic status attached to the result and reflects its meaning in HTTP form.

3. Compose Fluent Result Pipelines

var result = await userService.CreateUserAsync(dto)
    .Then(user => auditService.RecordCreation(user))
    .Map(_ => "User created");

You can wrap the final result into an IActionResult once the processing pipeline completes.


๐Ÿ” Upcoming Integration Capabilities

Feature Description
โœ… Automatic IActionResult Conversion IResult and IResult<T> will be automatically converted using a result adapter.
๐Ÿ“„ RFC 9457 ProblemDetails Output Failures will be serialized as Problem Details for HTTP APIs with full structure and metadata.
๐Ÿ“Š Observability Hooks Integrated telemetry injection via Zentient.Telemetry.
โš™๏ธ Pluggable Policies Full control over HTTP code mapping, problem shape, headers, and filters.
๐Ÿงฉ Minimal API Extensions Fluent registration and middleware like .WithZentientResults() for endpoint pipelines.

โš ๏ธ Remarks

  • Zentient.Results is transport-agnostic by contract and does not depend on ASP.NET Core.
  • ToProblemDetails() provides structured, machine-readable, and human-friendly error output aligned with ErrorInfo and IResultStatus.
  • The upcoming adapters in Zentient.Endpoints.Http will formalize integration patterns, allowing your domain to remain pure and framework-independent.

๐Ÿงฉ Integration Roadmap

The following roadmap outlines the status and targets of integration support within the Zentient ecosystem. All dedicated endpoint libraries begin at version v0.1.0 as pre-release packages under active development.

Layer Status Target Release
Minimal APIs โœ… Supported via manual wrapping Zentient.Endpoints.Http v0.1.0
Controller Actions โœ… Supported via ToProblemDetails() Zentient.Endpoints.Http v0.1.0
ProblemDetails (RFC 9457) โœ… Manually supported Zentient.Endpoints.Http v0.1.0
Telemetry Injection ๐Ÿšง In development Zentient.Telemetry v0.1.0
Error Handling Middleware ๐Ÿšง In development Zentient.Endpoints.Http v0.1.0
gRPC Integration ๐Ÿ”„ Planned Zentient.Endpoints.Grpc v0.1.0
Messaging Transports ๐Ÿงช Experimental Zentient.Endpoints.Messaging v0.1.0

All components will conform to RFC 9457 โ€“ Problem Details for HTTP APIs to ensure interoperable, machine-readable error semantics across all transport boundaries.

You can track progress and preview these adapters in the Zentient.Endpoints repository.


๐Ÿ“š See Also


๐Ÿท๏ธ Tags

#ASP.NETCore #Integration #ProblemDetails #HTTPAdapters #ZentientEndpoints #RFC9457 #StableContract


Last Updated: 2025-06-22 Version: 0.4.0

โš ๏ธ **GitHub.com Fallback** โš ๏ธ