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

Several proxy fixes as described in: #2204

Merged
merged 1 commit into from
Dec 14, 2017
Merged

Several proxy fixes as described in: #2204

merged 1 commit into from
Dec 14, 2017

Conversation

safihamid
Copy link
Contributor


if (function == null)
{
function = GetFunctionDescriptorFromRoute(request, _httpRoutes.GetRouteData(request));
Copy link
Member

@mathewc mathewc Dec 13, 2017

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();
    }
}

Copy link
Member

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)
Copy link
Member

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)
Copy link
Member

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 :)

Copy link
Member

@mathewc mathewc left a 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?

@safihamid safihamid merged commit 51d6ac5 into v1.x Dec 14, 2017
@safihamid safihamid deleted the proxyfixes branch December 14, 2017 00:17
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.

4 participants