-
Notifications
You must be signed in to change notification settings - Fork 447
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
Several proxy fixes as described in: #2204
Conversation
|
||
if (function == null) | ||
{ | ||
function = GetFunctionDescriptorFromRoute(request, _httpRoutes.GetRouteData(request)); |
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.
This double lookup scheme will mean we attempt to match against all function routes twice, in cases where functionRoutesFirst == true, and there isn't a match.
I wonder if it wouldn't be simpler to have a single route collection, and add a discriminator to IHttpRoute.DataTokens for each proxy. That would allow us to do filtered queries on the route collection, e.g. via an extension method something like:
public static class HttpRouteExtensions
{
public static IHttpRouteData GetRouteData(this HttpRouteCollection routes, HttpRequestMessage request, bool functionRoutesFirst = false)
{
IEnumerable<IHttpRoute> orderedRoutes = routes;
if (functionRoutesFirst)
{
orderedRoutes = routes.OrderBy(p => !(bool)p.DataTokens["IsProxyRoute"]);
}
return orderedRoutes.Select(p => p.GetRouteData(routes.VirtualPathRoot, request)).FirstOrDefault();
}
}
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.
Pull request here: #2222
@@ -14,7 +14,7 @@ internal class ProxyFunctionInvoker : FunctionInvokerBase | |||
private ProxyClientExecutor _proxyClient; | |||
|
|||
public ProxyFunctionInvoker(ScriptHost host, FunctionMetadata functionMetadata, ProxyClientExecutor proxyClient) | |||
: base(host, functionMetadata, logDirName: "Proxy") | |||
: base(host, functionMetadata) |
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.
Why this change?
// 1. If the request maps to a local http trigger function name then that function will be picked. | ||
// 2. Else if the request maps to a custom route of a local http trigger function then that function will be picked | ||
// 3. Otherwise the request will be given to asp.net to pick the appropriate route. | ||
foreach (var func in _scriptHostManager.HttpFunctions.Values) |
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.
Good to see all this complexity go away :)
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.
Suggestion for possible improvement - what do you think?
96d0178
to
51d6ac5
Compare
#2161
Azure/Azure-Functions#614
Azure/Azure-Functions#596