-
-
Notifications
You must be signed in to change notification settings - Fork 83
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
base: master
Are you sure you want to change the base?
Conversation
Cool! I will take a look tonight. |
There was a problem hiding this 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); |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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; |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
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.