-
i have yarp implemented using the direct forward pattern. in the endpoints.Map block i am checking for a condition. if the condition is not met, i would like to invoke the underlying controller that maps to the route instead of forwarding the request. is there any way to do this? as of now, if nothing occurs in the endpoints.Map block, it just returns a blank 200
|
Beta Was this translation helpful? Give feedback.
Answered by
Tratcher
Jul 3, 2022
Replies: 1 comment 1 reply
-
Move the forwarder to a middleware: app.Use((context, next) =>
{
if (conditionIsMet)
{
var error = await forwarder.SendAsync(httpContext, endpoint), httpClient, requestOptions, transformer);
// Check if the proxy operation was successful
if (error != ForwarderError.None)
{
var errorFeature = httpContext.Features.Get<IForwarderErrorFeature>();
var exception = errorFeature.Exception;
}
}
else
{
await next(context);
}
});
app.UseEndpoints(...) |
Beta Was this translation helpful? Give feedback.
1 reply
Answer selected by
pkycho92
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Move the forwarder to a middleware: