diff --git a/Routing.sln b/Routing.sln
index 68007039ac..4e09536d3e 100644
--- a/Routing.sln
+++ b/Routing.sln
@@ -1,6 +1,6 @@
Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 15
-VisualStudioVersion = 15.0.26824.3000
+VisualStudioVersion = 15.0.26927.0
MinimumVisualStudioVersion = 15.0.26730.03
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{0E966C37-7334-4D96-AAF6-9F49FBD166E3}"
ProjectSection(SolutionItems) = preProject
@@ -53,10 +53,12 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.AspNetCore.Dispat
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.AspNetCore.Dispatcher.Abstractions.Test", "test\Microsoft.AspNetCore.Dispatcher.Abstractions.Test\Microsoft.AspNetCore.Dispatcher.Abstractions.Test.csproj", "{14ACBCB4-3B99-425F-A5E2-07E228DEBF63}"
EndProject
-Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DispatcherSample", "samples\DispatcherSample\DispatcherSample.csproj", "{6EBC8AE2-CFF7-46E1-8427-9111FD4F3E85}"
+Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "DispatcherSample", "samples\DispatcherSample\DispatcherSample.csproj", "{6EBC8AE2-CFF7-46E1-8427-9111FD4F3E85}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.AspNetCore.Dispatcher.Performance", "benchmarks\Microsoft.AspNetCore.Dispatcher.Performance\Microsoft.AspNetCore.Dispatcher.Performance.csproj", "{30AF355D-E3AB-4FF5-8A59-A253AFEBA26A}"
EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Microsoft.AspNetCore.Dispatcher.FunctionalTest", "test\Microsoft.AspNetCore.Dispatcher.FunctionalTest\Microsoft.AspNetCore.Dispatcher.FunctionalTest.csproj", "{32107601-C9BE-467B-894C-C9F2E35F03E4}"
+EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
@@ -229,6 +231,18 @@ Global
{30AF355D-E3AB-4FF5-8A59-A253AFEBA26A}.Release|Mixed Platforms.Build.0 = Release|Any CPU
{30AF355D-E3AB-4FF5-8A59-A253AFEBA26A}.Release|x86.ActiveCfg = Release|Any CPU
{30AF355D-E3AB-4FF5-8A59-A253AFEBA26A}.Release|x86.Build.0 = Release|Any CPU
+ {32107601-C9BE-467B-894C-C9F2E35F03E4}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {32107601-C9BE-467B-894C-C9F2E35F03E4}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {32107601-C9BE-467B-894C-C9F2E35F03E4}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU
+ {32107601-C9BE-467B-894C-C9F2E35F03E4}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU
+ {32107601-C9BE-467B-894C-C9F2E35F03E4}.Debug|x86.ActiveCfg = Debug|Any CPU
+ {32107601-C9BE-467B-894C-C9F2E35F03E4}.Debug|x86.Build.0 = Debug|Any CPU
+ {32107601-C9BE-467B-894C-C9F2E35F03E4}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {32107601-C9BE-467B-894C-C9F2E35F03E4}.Release|Any CPU.Build.0 = Release|Any CPU
+ {32107601-C9BE-467B-894C-C9F2E35F03E4}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU
+ {32107601-C9BE-467B-894C-C9F2E35F03E4}.Release|Mixed Platforms.Build.0 = Release|Any CPU
+ {32107601-C9BE-467B-894C-C9F2E35F03E4}.Release|x86.ActiveCfg = Release|Any CPU
+ {32107601-C9BE-467B-894C-C9F2E35F03E4}.Release|x86.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
@@ -248,6 +262,7 @@ Global
{14ACBCB4-3B99-425F-A5E2-07E228DEBF63} = {95359B4B-4C85-4B44-A75B-0621905C4CF6}
{6EBC8AE2-CFF7-46E1-8427-9111FD4F3E85} = {C3ADD55B-B9C7-4061-8AD4-6A70D1AE3B2E}
{30AF355D-E3AB-4FF5-8A59-A253AFEBA26A} = {D5F39F59-5725-4127-82E7-67028D006185}
+ {32107601-C9BE-467B-894C-C9F2E35F03E4} = {95359B4B-4C85-4B44-A75B-0621905C4CF6}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {36C8D815-B7F1-479D-894B-E606FB8DECDA}
diff --git a/shared/Microsoft.AspNetCore.Routing.DecisionTree.Sourcesobj/Microsoft.AspNetCore.Routing.DecisionTree.Sources.2.1.0-preview1-t000.nuspec b/shared/Microsoft.AspNetCore.Routing.DecisionTree.Sourcesobj/Microsoft.AspNetCore.Routing.DecisionTree.Sources.2.1.0-preview1-t000.nuspec
new file mode 100644
index 0000000000..afa65da9fb
--- /dev/null
+++ b/shared/Microsoft.AspNetCore.Routing.DecisionTree.Sourcesobj/Microsoft.AspNetCore.Routing.DecisionTree.Sources.2.1.0-preview1-t000.nuspec
@@ -0,0 +1,33 @@
+
+
+
+ Microsoft.AspNetCore.Routing.DecisionTree.Sources
+ 2.1.0-preview1-t000
+ sharedsources
+ sharedsources
+ false
+ Microsoft.AspNetCore.Routing.DecisionTree.Sources
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/shared/Microsoft.AspNetCore.Routing.DecisionTree.Sourcesobj/project.assets.json b/shared/Microsoft.AspNetCore.Routing.DecisionTree.Sourcesobj/project.assets.json
new file mode 100644
index 0000000000..b00adfda03
--- /dev/null
+++ b/shared/Microsoft.AspNetCore.Routing.DecisionTree.Sourcesobj/project.assets.json
@@ -0,0 +1,52 @@
+{
+ "version": 3,
+ "targets": {
+ ".NETStandard,Version=v1.0": {}
+ },
+ "libraries": {},
+ "projectFileDependencyGroups": {
+ ".NETStandard,Version=v1.0": []
+ },
+ "packageFolders": {
+ "C:\\Users\\rynowak\\.nuget\\packages\\": {}
+ },
+ "project": {
+ "version": "2.1.0-preview1-t000",
+ "restore": {
+ "projectUniqueName": "C:\\Users\\rynowak\\.dotnet\\buildtools\\korebuild\\2.1.0-preview1-15509\\modules\\sharedsources\\sharedsources.csproj",
+ "projectName": "Microsoft.AspNetCore.Routing.DecisionTree.Sources",
+ "projectPath": "C:\\Users\\rynowak\\.dotnet\\buildtools\\korebuild\\2.1.0-preview1-15509\\modules\\sharedsources\\sharedsources.csproj",
+ "packagesPath": "C:\\Users\\rynowak\\.nuget\\packages\\",
+ "outputPath": "D:\\k\\Routing/shared/Microsoft.AspNetCore.Routing.DecisionTree.Sourcesobj\\",
+ "projectStyle": "PackageReference",
+ "configFilePaths": [
+ "C:\\Users\\rynowak\\AppData\\Roaming\\NuGet\\NuGet.Config",
+ "C:\\Program Files (x86)\\NuGet\\Config\\Microsoft.VisualStudio.Offline.config"
+ ],
+ "originalTargetFrameworks": [
+ "netstandard1.0"
+ ],
+ "sources": {
+ "C:\\Program Files (x86)\\Microsoft SDKs\\NuGetPackages\\": {},
+ "C:\\Users\\rynowak\\.dotnet\\NuGetFallbackFolder": {},
+ "C:\\Users\\rynowak\\.dotnet\\x64\\sdk\\NuGetFallbackFolder": {},
+ "C:\\Users\\rynowak\\private_nuget": {},
+ "https://www.nuget.org/api/v2/": {}
+ },
+ "frameworks": {
+ "netstandard1.0": {
+ "projectReferences": {}
+ }
+ },
+ "warningProperties": {
+ "allWarningsAsErrors": true,
+ "warnAsError": [
+ "NU1605"
+ ]
+ }
+ },
+ "frameworks": {
+ "netstandard1.0": {}
+ }
+ }
+}
\ No newline at end of file
diff --git a/shared/Microsoft.AspNetCore.Routing.DecisionTree.Sourcesobj/sharedsources.csproj.nuget.g.props b/shared/Microsoft.AspNetCore.Routing.DecisionTree.Sourcesobj/sharedsources.csproj.nuget.g.props
new file mode 100644
index 0000000000..b85f9b2c87
--- /dev/null
+++ b/shared/Microsoft.AspNetCore.Routing.DecisionTree.Sourcesobj/sharedsources.csproj.nuget.g.props
@@ -0,0 +1,15 @@
+
+
+
+ True
+ NuGet
+ D:\k\Routing\shared\Microsoft.AspNetCore.Routing.DecisionTree.Sourcesobj\project.assets.json
+ $(UserProfile)\.nuget\packages\
+ C:\Users\rynowak\.nuget\packages\
+ PackageReference
+ 4.4.0
+
+
+ $(MSBuildAllProjects);$(MSBuildThisFileFullPath)
+
+
\ No newline at end of file
diff --git a/shared/Microsoft.AspNetCore.Routing.DecisionTree.Sourcesobj/sharedsources.csproj.nuget.g.targets b/shared/Microsoft.AspNetCore.Routing.DecisionTree.Sourcesobj/sharedsources.csproj.nuget.g.targets
new file mode 100644
index 0000000000..53cfaa19b1
--- /dev/null
+++ b/shared/Microsoft.AspNetCore.Routing.DecisionTree.Sourcesobj/sharedsources.csproj.nuget.g.targets
@@ -0,0 +1,6 @@
+
+
+
+ $(MSBuildAllProjects);$(MSBuildThisFileFullPath)
+
+
\ No newline at end of file
diff --git a/test/Microsoft.AspNetCore.Dispatcher.FunctionalTest/ApiAppFixture.cs b/test/Microsoft.AspNetCore.Dispatcher.FunctionalTest/ApiAppFixture.cs
new file mode 100644
index 0000000000..f699935574
--- /dev/null
+++ b/test/Microsoft.AspNetCore.Dispatcher.FunctionalTest/ApiAppFixture.cs
@@ -0,0 +1,34 @@
+// Copyright (c) .NET Foundation. All rights reserved.
+// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
+
+using System;
+using System.Net.Http;
+using Microsoft.AspNetCore.Hosting;
+using Microsoft.AspNetCore.TestHost;
+
+namespace Microsoft.AspNetCore.Dispatcher.FunctionalTest
+{
+ public class ApiAppFixture : IDisposable
+ {
+ public ApiAppFixture()
+ {
+ var builder = new WebHostBuilder();
+ builder.UseStartup();
+
+ Server = new TestServer(builder);
+
+ Client = Server.CreateClient();
+ Client.BaseAddress = new Uri("http://locahost");
+ }
+
+ public HttpClient Client { get; }
+
+ public TestServer Server { get; }
+
+ public void Dispose()
+ {
+ Client.Dispose();
+ Server.Dispose();
+ }
+ }
+}
diff --git a/test/Microsoft.AspNetCore.Dispatcher.FunctionalTest/ApiAppStartup.cs b/test/Microsoft.AspNetCore.Dispatcher.FunctionalTest/ApiAppStartup.cs
new file mode 100644
index 0000000000..02e8ea95ab
--- /dev/null
+++ b/test/Microsoft.AspNetCore.Dispatcher.FunctionalTest/ApiAppStartup.cs
@@ -0,0 +1,80 @@
+// Copyright (c) .NET Foundation. All rights reserved.
+// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
+
+using System.Linq;
+using System.Threading.Tasks;
+using Microsoft.AspNetCore.Builder;
+using Microsoft.AspNetCore.Http;
+using Microsoft.AspNetCore.Routing.Dispatcher;
+using Microsoft.Extensions.DependencyInjection;
+using Microsoft.Extensions.Logging;
+
+namespace Microsoft.AspNetCore.Dispatcher.FunctionalTest
+{
+ public class ApiAppStartup
+ {
+ public void ConfigureServices(IServiceCollection services)
+ {
+ services.AddLogging();
+ services.AddDispatcher();
+ services.AddRouting();
+
+ services.Configure(ConfigureDispatcher);
+ }
+
+ public void Configure(IApplicationBuilder app, ILogger logger)
+ {
+ app.UseDispatcher();
+
+ app.Use(next => async (context) =>
+ {
+ logger.LogInformation("Executing fake CORS middleware");
+
+ var feature = context.Features.Get();
+ var policy = feature.Endpoint?.Metadata.OfType().LastOrDefault();
+ logger.LogInformation("using CORS policy {PolicyName}", policy?.Name ?? "default");
+
+ await next(context);
+ });
+
+ app.Use(next => async (context) =>
+ {
+ logger.LogInformation("Executing fake AuthZ middleware");
+
+ var feature = context.Features.Get();
+ var policy = feature.Endpoint?.Metadata.OfType().LastOrDefault();
+ if (policy != null)
+ {
+ logger.LogInformation("using Auth policy {PolicyName}", policy.Name);
+ }
+
+ await next(context);
+ });
+ }
+
+ public void ConfigureDispatcher(DispatcherOptions options)
+ {
+ options.Dispatchers.Add(new TreeDispatcher()
+ {
+ Endpoints =
+ {
+ new SimpleEndpoint(Products_Get, new object[]{ new RouteTemplateMetadata("api/products"), }),
+ },
+ });
+
+ options.HandlerFactories.Add(endpoint => (endpoint as SimpleEndpoint)?.HandlerFactory);
+ }
+
+ private Task Products_Get(HttpContext httpContext) => httpContext.Response.WriteAsync("Hello, Products_Get");
+
+ private class CorsPolicyMetadata
+ {
+ public string Name { get; set; }
+ }
+
+ private class AuthorizationPolicyMetadata
+ {
+ public string Name { get; set; }
+ }
+ }
+}
diff --git a/test/Microsoft.AspNetCore.Dispatcher.FunctionalTest/ApiAppTest.cs b/test/Microsoft.AspNetCore.Dispatcher.FunctionalTest/ApiAppTest.cs
new file mode 100644
index 0000000000..6a1eb005fe
--- /dev/null
+++ b/test/Microsoft.AspNetCore.Dispatcher.FunctionalTest/ApiAppTest.cs
@@ -0,0 +1,34 @@
+// Copyright (c) .NET Foundation. All rights reserved.
+// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
+
+using System.Net;
+using System.Net.Http;
+using System.Threading.Tasks;
+using Xunit;
+
+namespace Microsoft.AspNetCore.Dispatcher.FunctionalTest
+{
+ public class ApiAppTest : IClassFixture
+ {
+ public ApiAppTest(ApiAppFixture app)
+ {
+ Client = app.Client;
+ }
+
+ public HttpClient Client { get; }
+
+ [Fact]
+ public async Task ApiApp_CanRouteTo_LiteralEndpoint()
+ {
+ // Arrange
+ var request = new HttpRequestMessage(HttpMethod.Get, "/api/products");
+
+ // Act
+ var response = await Client.SendAsync(request);
+
+ // Assert
+ Assert.Equal(HttpStatusCode.OK, response.StatusCode);
+ Assert.Equal("Hello, Products_Get", await response.Content.ReadAsStringAsync());
+ }
+ }
+}
diff --git a/test/Microsoft.AspNetCore.Dispatcher.FunctionalTest/Microsoft.AspNetCore.Dispatcher.FunctionalTest.csproj b/test/Microsoft.AspNetCore.Dispatcher.FunctionalTest/Microsoft.AspNetCore.Dispatcher.FunctionalTest.csproj
new file mode 100644
index 0000000000..2f1627078d
--- /dev/null
+++ b/test/Microsoft.AspNetCore.Dispatcher.FunctionalTest/Microsoft.AspNetCore.Dispatcher.FunctionalTest.csproj
@@ -0,0 +1,16 @@
+
+
+
+ netcoreapp2.0;net461
+ netcoreapp2.0
+
+
+
+
+
+
+
+
+
+
+