Consider New Ardalis.Result.FastEndpoints package with base classes, extension methods
- Dominant language
- C#
- Stars
- 1k
- Forks
- 127
- PR merge metrics
- No merged PRs in 30d
Description
For example this code from a devBetter.com member:
```csharp
public abstract class EndpointBase : Endpoint where TRequest : notnull where TResponse : notnull where TMapper : class, IResponseMapper
{
public override async Task ExecuteAsync(TRequest req, CancellationToken ct)
{
Result response = await ProcessAsync(req, ct)
.ConfigureAwait(false);
this.AddResultErrors(response);
ThrowIfAnyErrors();
return response
.ToMinimalApiResult();
}
public abstract Task> ProcessAsync(TRequest request, CancellationToken cancellationToken);
}
// or similar by nhwilly
public abstract class EndpointBase : Endpoint where TRequest : notnull where TResponse : notnull
{
public override async Task ExecuteAsync(TRequest req, CancellationToken ct)
{
Result response = await ProcessAsync(req, ct)
.ConfigureAwait(false);
this.AddResultErrors(response);
ThrowIfAnyErrors();
return response.ToMinimalApiResult();
}
public abstract Task> ProcessAsync(TRequest request, CancellationToken cancellationToken);
}
```
Contributor guide
Research direction
Start by reviewing the two proposed EndpointBase examples and the referenced AddResultErrors and ToMinimalApiResult calls. Define the package scope, base-class variants, and extension methods before implementation; done should include an agreed design and corresponding tests.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- csharp
- Domain
- backend-api-design
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100