Using FastEndpoints Postprocessor and the SendResultAsync with .ToMinimalApiResult extension doesn't provide the filled "Result" in the context #221
Open
Description
I'm experimenting with FastEndpoints and I have an endpoint that finishes with the following call in the HandleAsync method:
Endpoint class:
internal class LoginEndpoint : Endpoint<LoginRequest, Result<LoginResponse>>
Handler method:
public override async Task HandleAsync(LoginRequest req, CancellationToken ct)
{
var loginResponse = ...;
...//login response is of the Result<LoginResponse> type
await SendResultAsync(loginResponse.ToMinimalApiResult());
}
Configure method:
public override void Configure()
{
Verbs(Http.POST);
Routes("/login");
AllowAnonymous();
PostProcessor<LoginPostProcessor>();
}
And the LoginPostProcessor:
internal class LoginPostProcessor : IPostProcessor<LoginRequest, Result<LoginResponse>>
{
public async Task PostProcessAsync(IPostProcessorContext<LoginRequest, Result<LoginResponse>> context, CancellationToken ct)
{
if(context.Response?.Status == ResultStatus.Ok) // Login successful
{
//...do something
}
}
}
But the context.Response is null.
When I finish my Handler method just by this call:
await SendAsync(loginResponse, cancellation: ct);
then everything works....
Am I doing something wrong?
Metadata
Assignees
Labels
No labels