Skip to content
Discussion options

You must be logged in to vote

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(...)

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@pkycho92
Comment options

Answer selected by pkycho92
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants