Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Stop Middleware shortcutting when filter is used #81

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

rtkelly13
Copy link

Implementation for #80

This change passes a bool up the stack to the middleware layer to say if the pipeline should be short-circuited

I think this first go isn't probably the right approach but is worth having a discussion over to see what is needed.

@twitchax
Copy link
Owner

Cool! I will take a look tonight.

Copy link
Owner

@twitchax twitchax left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Overall, LGTM, but I might add an enum to make the Intercept and Filter options easier to understand.

{
var httpProxy = new HttpProxy((c, a) => new ValueTask<string>(httpEndpoint), httpProxyOptions);
var wsProxy = new WsProxy((c, a) => new ValueTask<string>(wsEndpoint), wsProxyOptions);
var proxy = new Builders.Proxy(null, httpProxy, wsProxy);
return controller.HttpContext.ExecuteProxyOperationAsync(proxy);
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Might want to show the throwaway result.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah I wasn't sure on this one, didn't want to change the API but the user of this API can still choose to ignore the result and it should be their choice, an Enum would be the best output for them

@@ -23,9 +23,14 @@ internal static async Task ExecuteHttpProxyOperationAsync(this HttpContext conte
.GetService<IHttpClientFactory>()
.CreateClient(options?.HttpClientName ?? Helpers.HttpProxyClientName);

if (options?.Filter != null && !options.Filter(context))
{
return false;
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can probably keep this, but I feel like, now that there are two filter options, this may call for an enum to be more clear than a bool. I might just clean it up after, and then bump a major version.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You're right, I wanted to add it with boolean because it would be the simplest implementation. But the code is much more confusing because of that, an Enum absolutely solves this. I'll try to make a change later today.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants