Table of Contents

Class ResultMappingExtensions

Namespace
Olve.MinimalApi
Assembly
Olve.MinimalApi.dll

Provides extension methods to map Result and Result<T> to minimal API HTTP responses. A failure answers 404 Not Found when any of its problems is a NotFoundProblem, and 400 Bad Request otherwise; either way the body is the ResultProblem array.

public static class ResultMappingExtensions
Inheritance
ResultMappingExtensions
Inherited Members

Methods

ToHttpResult(Result)

Converts a Result into an IResult HTTP response.

public static IResult ToHttpResult(this Result result)

Parameters

result Result

The Result to convert.

Returns

IResult

An IResult representing the HTTP response: OK, or NotFound/BadRequest with problems.

ToHttpResult<T>(Result<T>)

Converts a Result<T> into an IResult HTTP response.

public static IResult ToHttpResult<T>(this Result<T> result)

Parameters

result Result<T>

The Result<T> to convert.

Returns

IResult

An IResult representing the HTTP response: OK with value, or NotFound/BadRequest with problems.

Type Parameters

T

The type of the result value.

WithResultMapping(RouteHandlerBuilder)

Configures the endpoint to produce success and error HTTP responses based on Result.

public static RouteHandlerBuilder WithResultMapping(this RouteHandlerBuilder builder)

Parameters

builder RouteHandlerBuilder

The route handler builder to configure.

Returns

RouteHandlerBuilder

The configured RouteHandlerBuilder.

WithResultMapping<TResult>(RouteHandlerBuilder)

Configures the endpoint to produce success and error HTTP responses based on Result<T>.

public static RouteHandlerBuilder WithResultMapping<TResult>(this RouteHandlerBuilder builder)

Parameters

builder RouteHandlerBuilder

The route handler builder to configure.

Returns

RouteHandlerBuilder

The configured RouteHandlerBuilder.

Type Parameters

TResult

The type of the result value.