Open ardalis opened 5 months ago
For example this code from a devBetter.com member:
public abstract class EndpointBase<TRequest, TResponse, TMapper> : Endpoint<TRequest, IResult, TMapper> where TRequest : notnull where TResponse : notnull where TMapper : class, IResponseMapper { public override async Task<IResult> ExecuteAsync(TRequest req, CancellationToken ct) { Result<TResponse> response = await ProcessAsync(req, ct) .ConfigureAwait(false); this.AddResultErrors(response); ThrowIfAnyErrors(); return response .ToMinimalApiResult(); } public abstract Task<Result<TResponse>> ProcessAsync(TRequest request, CancellationToken cancellationToken); } // or similar by nhwilly public abstract class EndpointBase<TRequest, TResponse> : Endpoint<TRequest, Microsoft.AspNetCore.Http.IResult> where TRequest : notnull where TResponse : notnull { public override async Task<Microsoft.AspNetCore.Http.IResult> ExecuteAsync(TRequest req, CancellationToken ct) { Result<TResponse> response = await ProcessAsync(req, ct) .ConfigureAwait(false); this.AddResultErrors(response); ThrowIfAnyErrors(); return response.ToMinimalApiResult(); } public abstract Task<Result<TResponse>> ProcessAsync(TRequest request, CancellationToken cancellationToken); }
See: #157
I tried that, but quickly ran into limitations for 201 and we'd have to subclass other varieties, for no dto returned, etc. I backed off until I have more time later.
See #174
For example this code from a devBetter.com member: