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.

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, either OK or 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, either OK with value or 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.