-
Notifications
You must be signed in to change notification settings - Fork 112
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add Support For FastEndpoints #157
Labels
enhancement
New feature or request
Comments
FastEndpoint already has a |
It might need something like this: static class ArdalisResultsExtensions
{
public static async Task SendResponse<TResult, TResponse>(this IEndpoint ep, TResult result, Func<TResult, TResponse> mapper) where TResult : Ardalis.Result.IResult
{
switch (result.Status)
{
case ResultStatus.Ok:
await ep.HttpContext.Response.SendAsync(mapper(result));
break;
case ResultStatus.Conflict:
await ep.HttpContext.Response.SendAsync(result.Errors, 409);
break;
case ResultStatus.Invalid:
result.ValidationErrors.ToList().ForEach(e =>
ep.ValidationFailures.Add(new(e.Identifier, e.ErrorMessage)));
await ep.HttpContext.Response.SendErrorsAsync(ep.ValidationFailures);
break;
}
}
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
We already have support for Minimal API results so it would be awesome to see what work is needed to also support FastEndpoints like we do for Controllers/APIEndpoints. If any code is needed it could probably be added to the AspNetCore package unless we would like to add an Ardalis.Result.FastEndpoints package
The text was updated successfully, but these errors were encountered: