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)
public static IResult ToHttpResult(this Result result)
Parameters
Returns
ToHttpResult<T>(Result<T>)
public static IResult ToHttpResult<T>(this Result<T> result)
Parameters
Returns
- IResult
An IResult representing the HTTP response: OK with value, or NotFound/BadRequest with problems.
Type Parameters
TThe 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
builderRouteHandlerBuilderThe 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
builderRouteHandlerBuilderThe route handler builder to configure.
Returns
- RouteHandlerBuilder
The configured RouteHandlerBuilder.
Type Parameters
TResultThe type of the result value.