From 20967cfa76913ee7acfe6d737877fa0af3c11e11 Mon Sep 17 00:00:00 2001 From: Kiran Challa Date: Mon, 12 Dec 2016 12:27:15 -0800 Subject: [PATCH] [Fixes #367] Add extensions on WebHostBuilder for super simple HTTP service application building --- samples/RoutingSample.Web/Program.cs | 50 ++++++++ samples/RoutingSample.Web/Startup.cs | 56 --------- .../RequestDelegateRouteBuilderExtensions.cs | 108 ++++++++++++++++-- .../exceptions.net45.json | 32 ++++++ .../exceptions.netcore.json | 32 ++++++ .../RoutingSampleTest.cs | 30 +++-- .../WebHostBuilderExtensionsTest.cs | 101 ++++++++++++++++ ...questDelegateRouteBuilderExtensionsTest.cs | 34 +++--- 8 files changed, 351 insertions(+), 92 deletions(-) create mode 100644 samples/RoutingSample.Web/Program.cs delete mode 100644 samples/RoutingSample.Web/Startup.cs create mode 100644 src/Microsoft.AspNetCore.Routing/exceptions.net45.json create mode 100644 src/Microsoft.AspNetCore.Routing/exceptions.netcore.json create mode 100644 test/Microsoft.AspNetCore.Routing.FunctionalTests/WebHostBuilderExtensionsTest.cs diff --git a/samples/RoutingSample.Web/Program.cs b/samples/RoutingSample.Web/Program.cs new file mode 100644 index 0000000000..27a1a8b55e --- /dev/null +++ b/samples/RoutingSample.Web/Program.cs @@ -0,0 +1,50 @@ +// 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.Text.RegularExpressions; +using Microsoft.AspNetCore.Builder; +using Microsoft.AspNetCore.Hosting; +using Microsoft.AspNetCore.Http; +using Microsoft.AspNetCore.Routing; +using Microsoft.AspNetCore.Routing.Constraints; +using Microsoft.Extensions.DependencyInjection; + +namespace RoutingSample.Web +{ + public class Program + { + private static readonly TimeSpan RegexMatchTimeout = TimeSpan.FromSeconds(10); + + public static void Main(string[] args) + { + var webHost = GetWebHostBuilder().Build(); + webHost.Run(); + } + + // For unit testing + public static IWebHostBuilder GetWebHostBuilder() + { + return new WebHostBuilder() + .UseKestrel() + .UseIISIntegration() + .ConfigureServices(services => services.AddRouting()) + .Configure(app => app.UseRouter(routes => + { + routes.DefaultHandler = new RouteHandler((httpContext) => + { + var request = httpContext.Request; + return httpContext.Response.WriteAsync($"Verb = {request.Method.ToUpperInvariant()} - Path = {request.Path} - Route values - {string.Join(", ", httpContext.GetRouteData().Values)}"); + }); + + routes.MapGet("api/get/{id}", (request, response, routeData) => response.WriteAsync($"API Get {routeData.Values["id"]}")) + .MapMiddlewareRoute("api/middleware", (appBuilder) => appBuilder.Use((httpContext, next) => httpContext.Response.WriteAsync("Middleware!"))) + .MapRoute( + name: "AllVerbs", + template: "api/all/{name}/{lastName?}", + defaults: new { lastName = "Doe" }, + constraints: new { lastName = new RegexRouteConstraint(new Regex("[a-zA-Z]{3}", RegexOptions.CultureInvariant, RegexMatchTimeout)) }); + })); + } + } +} diff --git a/samples/RoutingSample.Web/Startup.cs b/samples/RoutingSample.Web/Startup.cs deleted file mode 100644 index 4e5498af3f..0000000000 --- a/samples/RoutingSample.Web/Startup.cs +++ /dev/null @@ -1,56 +0,0 @@ -// 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.Text.RegularExpressions; -using Microsoft.AspNetCore.Builder; -using Microsoft.AspNetCore.Hosting; -using Microsoft.AspNetCore.Http; -using Microsoft.AspNetCore.Routing; -using Microsoft.AspNetCore.Routing.Constraints; -using Microsoft.Extensions.DependencyInjection; - -namespace RoutingSample.Web -{ - public class Startup - { - private static readonly TimeSpan RegexMatchTimeout = TimeSpan.FromSeconds(10); - - public void ConfigureServices(IServiceCollection services) - { - services.AddRouting(); - } - - public void Configure(IApplicationBuilder app) - { - app.UseRouter(routes => - { - routes.DefaultHandler = new RouteHandler((c) => - { - return c.Response.WriteAsync($"Verb = {c.Request.Method.ToUpperInvariant()} - Path = {c.Request.Path} - Route values - {string.Join(", ", c.GetRouteData().Values)}"); - }); - - routes.MapGet("api/get/{id}", (c) => c.Response.WriteAsync($"API Get {c.GetRouteData().Values["id"]}")); - - routes.MapRoute("api/middleware", (IApplicationBuilder fork) => fork.Use((c, n) => c.Response.WriteAsync("Middleware!"))); - - routes.MapRoute( - name: "AllVerbs", - template: "api/all/{name}/{lastName?}", - defaults: new { lastName = "Doe" }, - constraints: new { lastName = new RegexRouteConstraint(new Regex("[a-zA-Z]{3}", RegexOptions.CultureInvariant, RegexMatchTimeout))}); - }); - } - - public static void Main(string[] args) - { - var host = new WebHostBuilder() - .UseKestrel() - .UseIISIntegration() - .UseStartup() - .Build(); - - host.Run(); - } - } -} \ No newline at end of file diff --git a/src/Microsoft.AspNetCore.Routing/RequestDelegateRouteBuilderExtensions.cs b/src/Microsoft.AspNetCore.Routing/RequestDelegateRouteBuilderExtensions.cs index 8b1827c4bb..f376683c4d 100644 --- a/src/Microsoft.AspNetCore.Routing/RequestDelegateRouteBuilderExtensions.cs +++ b/src/Microsoft.AspNetCore.Routing/RequestDelegateRouteBuilderExtensions.cs @@ -2,6 +2,7 @@ // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. using System; +using System.Threading.Tasks; using Microsoft.AspNetCore.Builder; using Microsoft.AspNetCore.Http; using Microsoft.AspNetCore.Routing.Constraints; @@ -41,7 +42,7 @@ namespace Microsoft.AspNetCore.Routing /// The route template. /// The action to apply to the . /// A reference to the after this operation has completed. - public static IRouteBuilder MapRoute(this IRouteBuilder builder, string template, Action action) + public static IRouteBuilder MapMiddlewareRoute(this IRouteBuilder builder, string template, Action action) { var nested = builder.ApplicationBuilder.New(); action(nested); @@ -69,9 +70,25 @@ namespace Microsoft.AspNetCore.Routing /// The route template. /// The action to apply to the . /// A reference to the after this operation has completed. - public static IRouteBuilder MapDelete(this IRouteBuilder builder, string template, Action action) + public static IRouteBuilder MapMiddlewareDelete(this IRouteBuilder builder, string template, Action action) { - return builder.MapVerb("DELETE", template, action); + return builder.MapMiddlewareVerb("DELETE", template, action); + } + + /// + /// Adds a route to the that only matches HTTP DELETE requests for the given + /// , and . + /// + /// The . + /// The route template. + /// The route handler. + /// A reference to the after this operation has completed. + public static IRouteBuilder MapDelete( + this IRouteBuilder builder, + string template, + Func handler) + { + return builder.MapVerb("DELETE", template, handler); } /// @@ -95,9 +112,25 @@ namespace Microsoft.AspNetCore.Routing /// The route template. /// The action to apply to the . /// A reference to the after this operation has completed. - public static IRouteBuilder MapGet(this IRouteBuilder builder, string template, Action action) + public static IRouteBuilder MapMiddlewareGet(this IRouteBuilder builder, string template, Action action) { - return builder.MapVerb("GET", template, action); + return builder.MapMiddlewareVerb("GET", template, action); + } + + /// + /// Adds a route to the that only matches HTTP GET requests for the given + /// , and . + /// + /// The . + /// The route template. + /// The route handler. + /// A reference to the after this operation has completed. + public static IRouteBuilder MapGet( + this IRouteBuilder builder, + string template, + Func handler) + { + return builder.MapVerb("GET", template, handler); } /// @@ -121,9 +154,25 @@ namespace Microsoft.AspNetCore.Routing /// The route template. /// The action to apply to the . /// A reference to the after this operation has completed. - public static IRouteBuilder MapPost(this IRouteBuilder builder, string template, Action action) + public static IRouteBuilder MapMiddlewarePost(this IRouteBuilder builder, string template, Action action) { - return builder.MapVerb("POST", template, action); + return builder.MapMiddlewareVerb("POST", template, action); + } + + /// + /// Adds a route to the that only matches HTTP POST requests for the given + /// , and . + /// + /// The . + /// The route template. + /// The route handler. + /// A reference to the after this operation has completed. + public static IRouteBuilder MapPost( + this IRouteBuilder builder, + string template, + Func handler) + { + return builder.MapVerb("POST", template, handler); } /// @@ -147,9 +196,48 @@ namespace Microsoft.AspNetCore.Routing /// The route template. /// The action to apply to the . /// A reference to the after this operation has completed. - public static IRouteBuilder MapPut(this IRouteBuilder builder, string template, Action action) + public static IRouteBuilder MapMiddlewarePut(this IRouteBuilder builder, string template, Action action) { - return builder.MapVerb("PUT", template, action); + return builder.MapMiddlewareVerb("PUT", template, action); + } + + /// + /// Adds a route to the that only matches HTTP PUT requests for the given + /// , and . + /// + /// The . + /// The route template. + /// The route handler. + /// A reference to the after this operation has completed. + public static IRouteBuilder MapPut( + this IRouteBuilder builder, + string template, + Func handler) + { + return builder.MapVerb("PUT", template, handler); + } + + /// + /// Adds a route to the that only matches HTTP requests for the given + /// , , and . + /// + /// The . + /// The HTTP verb allowed by the route. + /// The route template. + /// The route handler. + /// A reference to the after this operation has completed. + public static IRouteBuilder MapVerb( + this IRouteBuilder builder, + string verb, + string template, + Func handler) + { + RequestDelegate requestDelegate = (httpContext) => + { + return handler(httpContext.Request, httpContext.Response, httpContext.GetRouteData()); + }; + + return builder.MapVerb(verb, template, requestDelegate); } /// @@ -188,7 +276,7 @@ namespace Microsoft.AspNetCore.Routing /// The route template. /// The action to apply to the . /// A reference to the after this operation has completed. - public static IRouteBuilder MapVerb( + public static IRouteBuilder MapMiddlewareVerb( this IRouteBuilder builder, string verb, string template, diff --git a/src/Microsoft.AspNetCore.Routing/exceptions.net45.json b/src/Microsoft.AspNetCore.Routing/exceptions.net45.json new file mode 100644 index 0000000000..33ef2f4392 --- /dev/null +++ b/src/Microsoft.AspNetCore.Routing/exceptions.net45.json @@ -0,0 +1,32 @@ +[ + { + "OldTypeId": "public static class Microsoft.AspNetCore.Routing.RequestDelegateRouteBuilderExtensions", + "OldMemberId": "public static Microsoft.AspNetCore.Routing.IRouteBuilder MapRoute(this Microsoft.AspNetCore.Routing.IRouteBuilder builder, System.String template, System.Action action)", + "Kind": "Removal" + }, + { + "OldTypeId": "public static class Microsoft.AspNetCore.Routing.RequestDelegateRouteBuilderExtensions", + "OldMemberId": "public static Microsoft.AspNetCore.Routing.IRouteBuilder MapGet(this Microsoft.AspNetCore.Routing.IRouteBuilder builder, System.String template, System.Action action)", + "Kind": "Removal" + }, + { + "OldTypeId": "public static class Microsoft.AspNetCore.Routing.RequestDelegateRouteBuilderExtensions", + "OldMemberId": "public static Microsoft.AspNetCore.Routing.IRouteBuilder MapPost(this Microsoft.AspNetCore.Routing.IRouteBuilder builder, System.String template, System.Action action)", + "Kind": "Removal" + }, + { + "OldTypeId": "public static class Microsoft.AspNetCore.Routing.RequestDelegateRouteBuilderExtensions", + "OldMemberId": "public static Microsoft.AspNetCore.Routing.IRouteBuilder MapPut(this Microsoft.AspNetCore.Routing.IRouteBuilder builder, System.String template, System.Action action)", + "Kind": "Removal" + }, + { + "OldTypeId": "public static class Microsoft.AspNetCore.Routing.RequestDelegateRouteBuilderExtensions", + "OldMemberId": "public static Microsoft.AspNetCore.Routing.IRouteBuilder MapDelete(this Microsoft.AspNetCore.Routing.IRouteBuilder builder, System.String template, System.Action action)", + "Kind": "Removal" + }, + { + "OldTypeId": "public static class Microsoft.AspNetCore.Routing.RequestDelegateRouteBuilderExtensions", + "OldMemberId": "public static Microsoft.AspNetCore.Routing.IRouteBuilder MapVerb(this Microsoft.AspNetCore.Routing.IRouteBuilder builder, System.String verb, System.String template, System.Action action)", + "Kind": "Removal" + } +] \ No newline at end of file diff --git a/src/Microsoft.AspNetCore.Routing/exceptions.netcore.json b/src/Microsoft.AspNetCore.Routing/exceptions.netcore.json new file mode 100644 index 0000000000..33ef2f4392 --- /dev/null +++ b/src/Microsoft.AspNetCore.Routing/exceptions.netcore.json @@ -0,0 +1,32 @@ +[ + { + "OldTypeId": "public static class Microsoft.AspNetCore.Routing.RequestDelegateRouteBuilderExtensions", + "OldMemberId": "public static Microsoft.AspNetCore.Routing.IRouteBuilder MapRoute(this Microsoft.AspNetCore.Routing.IRouteBuilder builder, System.String template, System.Action action)", + "Kind": "Removal" + }, + { + "OldTypeId": "public static class Microsoft.AspNetCore.Routing.RequestDelegateRouteBuilderExtensions", + "OldMemberId": "public static Microsoft.AspNetCore.Routing.IRouteBuilder MapGet(this Microsoft.AspNetCore.Routing.IRouteBuilder builder, System.String template, System.Action action)", + "Kind": "Removal" + }, + { + "OldTypeId": "public static class Microsoft.AspNetCore.Routing.RequestDelegateRouteBuilderExtensions", + "OldMemberId": "public static Microsoft.AspNetCore.Routing.IRouteBuilder MapPost(this Microsoft.AspNetCore.Routing.IRouteBuilder builder, System.String template, System.Action action)", + "Kind": "Removal" + }, + { + "OldTypeId": "public static class Microsoft.AspNetCore.Routing.RequestDelegateRouteBuilderExtensions", + "OldMemberId": "public static Microsoft.AspNetCore.Routing.IRouteBuilder MapPut(this Microsoft.AspNetCore.Routing.IRouteBuilder builder, System.String template, System.Action action)", + "Kind": "Removal" + }, + { + "OldTypeId": "public static class Microsoft.AspNetCore.Routing.RequestDelegateRouteBuilderExtensions", + "OldMemberId": "public static Microsoft.AspNetCore.Routing.IRouteBuilder MapDelete(this Microsoft.AspNetCore.Routing.IRouteBuilder builder, System.String template, System.Action action)", + "Kind": "Removal" + }, + { + "OldTypeId": "public static class Microsoft.AspNetCore.Routing.RequestDelegateRouteBuilderExtensions", + "OldMemberId": "public static Microsoft.AspNetCore.Routing.IRouteBuilder MapVerb(this Microsoft.AspNetCore.Routing.IRouteBuilder builder, System.String verb, System.String template, System.Action action)", + "Kind": "Removal" + } +] \ No newline at end of file diff --git a/test/Microsoft.AspNetCore.Routing.FunctionalTests/RoutingSampleTest.cs b/test/Microsoft.AspNetCore.Routing.FunctionalTests/RoutingSampleTest.cs index f0322f4d3d..8869103f40 100644 --- a/test/Microsoft.AspNetCore.Routing.FunctionalTests/RoutingSampleTest.cs +++ b/test/Microsoft.AspNetCore.Routing.FunctionalTests/RoutingSampleTest.cs @@ -1,21 +1,27 @@ // 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; using System.Net.Http; using System.Threading.Tasks; +using Microsoft.AspNetCore.TestHost; using Xunit; namespace Microsoft.AspNetCore.Routing.FunctionalTests { - public class RoutingSampleTest : IClassFixture> + public class RoutingSampleTest : IDisposable { - public RoutingSampleTest(RoutingTestFixture fixture) - { - Client = fixture.Client; - } + private readonly HttpClient _client; + private readonly TestServer _testServer; - public HttpClient Client { get; } + public RoutingSampleTest() + { + var webHostBuilder = RoutingSample.Web.Program.GetWebHostBuilder(); + _testServer = new TestServer(webHostBuilder); + _client = _testServer.CreateClient(); + _client.BaseAddress = new Uri("http://localhost"); + } [Fact] public async Task Routing_CanRouteRequestDelegate_ToSpecificHttpVerb() @@ -24,7 +30,7 @@ namespace Microsoft.AspNetCore.Routing.FunctionalTests var message = new HttpRequestMessage(HttpMethod.Get, "api/get/5"); // Act - var response = await Client.SendAsync(message); + var response = await _client.SendAsync(message); // Assert Assert.Equal(HttpStatusCode.OK, response.StatusCode); @@ -38,7 +44,7 @@ namespace Microsoft.AspNetCore.Routing.FunctionalTests var message = new HttpRequestMessage(HttpMethod.Get, "api/middleware"); // Act - var response = await Client.SendAsync(message); + var response = await _client.SendAsync(message); // Assert Assert.Equal(HttpStatusCode.OK, response.StatusCode); @@ -60,7 +66,7 @@ namespace Microsoft.AspNetCore.Routing.FunctionalTests var expectedBody = $"Verb = {httpVerb} - Path = /api/all/Joe/Duf - Route values - [name, Joe], [lastName, Duf]"; // Act - var response = await Client.SendAsync(message); + var response = await _client.SendAsync(message); // Assert Assert.Equal(HttpStatusCode.OK, response.StatusCode); @@ -68,5 +74,11 @@ namespace Microsoft.AspNetCore.Routing.FunctionalTests var body = await response.Content.ReadAsStringAsync(); Assert.Equal(expectedBody, body); } + + public void Dispose() + { + _testServer.Dispose(); + _client.Dispose(); + } } } diff --git a/test/Microsoft.AspNetCore.Routing.FunctionalTests/WebHostBuilderExtensionsTest.cs b/test/Microsoft.AspNetCore.Routing.FunctionalTests/WebHostBuilderExtensionsTest.cs new file mode 100644 index 0000000000..7466006026 --- /dev/null +++ b/test/Microsoft.AspNetCore.Routing.FunctionalTests/WebHostBuilderExtensionsTest.cs @@ -0,0 +1,101 @@ +// 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.IO; +using System.Net; +using System.Net.Http; +using System.Threading.Tasks; +using Microsoft.AspNetCore.Hosting; +using Microsoft.AspNetCore.Http; +using Microsoft.AspNetCore.Builder; +using Microsoft.AspNetCore.TestHost; +using Microsoft.Extensions.DependencyInjection; +using Xunit; + +namespace Microsoft.AspNetCore.Routing.FunctionalTests +{ + public class WebHostBuilderExtensionsTest + { + public static TheoryData, HttpRequestMessage, string> MatchesRequest + { + get + { + return new TheoryData, HttpRequestMessage, string>() + { + { + (rb) => rb.MapGet("greeting/{name}", (req, resp, routeData) => resp.WriteAsync($"Hello! {routeData.Values["name"]}")), + new HttpRequestMessage(HttpMethod.Get, "greeting/James"), + "Hello! James" + }, + { + (rb) => rb.MapPost( + "greeting/{name}", + async (req, resp, routeData) => + { + var streamReader = new StreamReader(req.Body); + var data = await streamReader.ReadToEndAsync(); + await resp.WriteAsync($"{routeData.Values["name"]} {data}"); + }), + new HttpRequestMessage(HttpMethod.Post, "greeting/James") { Content = new StringContent("Biography") }, + "James Biography" + }, + { + (rb) => rb.MapPut( + "greeting/{name}", + async (req, resp, routeData) => + { + var streamReader = new StreamReader(req.Body); + var data = await streamReader.ReadToEndAsync(); + await resp.WriteAsync($"{routeData.Values["name"]} {data}"); + }), + new HttpRequestMessage(HttpMethod.Put, "greeting/James") { Content = new StringContent("Biography") }, + "James Biography" + }, + { + (rb) => rb.MapDelete("greeting/{name}", (req, resp, routeData) => resp.WriteAsync($"Hello! {routeData.Values["name"]}")), + new HttpRequestMessage(HttpMethod.Delete, "greeting/James"), + "Hello! James" + }, + { + (rb) => rb.MapVerb( + "POST", + "greeting/{name}", + async (req, resp, routeData) => + { + var streamReader = new StreamReader(req.Body); + var data = await streamReader.ReadToEndAsync(); + await resp.WriteAsync($"{routeData.Values["name"]} {data}"); + }), + new HttpRequestMessage(HttpMethod.Post, "greeting/James") { Content = new StringContent("Biography") }, + "James Biography" + }, + }; + } + } + + [Theory] + [MemberData(nameof(MatchesRequest))] + public async Task UseRouter_MapGet_MatchesRequest(Action routeBuilder, HttpRequestMessage request, string expected) + { + // Arrange + var webhostbuilder = new WebHostBuilder(); + webhostbuilder + .ConfigureServices(services => services.AddRouting()) + .Configure(app => + { + app.UseRouter(routeBuilder); + }); + var testServer = new TestServer(webhostbuilder); + var client = testServer.CreateClient(); + + // Act + var response = await client.SendAsync(request); + + // Assert + Assert.Equal(HttpStatusCode.OK, response.StatusCode); + var actual = await response.Content.ReadAsStringAsync(); + Assert.Equal(expected, actual); + } + } +} diff --git a/test/Microsoft.AspNetCore.Routing.Tests/RequestDelegateRouteBuilderExtensionsTest.cs b/test/Microsoft.AspNetCore.Routing.Tests/RequestDelegateRouteBuilderExtensionsTest.cs index 52dbd5a590..534c193a93 100644 --- a/test/Microsoft.AspNetCore.Routing.Tests/RequestDelegateRouteBuilderExtensionsTest.cs +++ b/test/Microsoft.AspNetCore.Routing.Tests/RequestDelegateRouteBuilderExtensionsTest.cs @@ -25,19 +25,19 @@ namespace Microsoft.AspNetCore.Routing return new TheoryData, Action>() { { b => { b.MapRoute("api/{id}", NullHandler); }, null }, - { b => { b.MapRoute("api/{id}", app => { }); }, null }, + { b => { b.MapMiddlewareRoute("api/{id}", app => { }); }, null }, { b => { b.MapDelete("api/{id}", NullHandler); }, c => { c.Request.Method = "DELETE"; } }, - { b => { b.MapDelete("api/{id}", app => { }); }, c => { c.Request.Method = "DELETE"; } }, + { b => { b.MapMiddlewareDelete("api/{id}", app => { }); }, c => { c.Request.Method = "DELETE"; } }, { b => { b.MapGet("api/{id}", NullHandler); }, c => { c.Request.Method = "GET"; } }, - { b => { b.MapGet("api/{id}", app => { }); }, c => { c.Request.Method = "GET"; } }, + { b => { b.MapMiddlewareGet("api/{id}", app => { }); }, c => { c.Request.Method = "GET"; } }, { b => { b.MapPost("api/{id}", NullHandler); }, c => { c.Request.Method = "POST"; } }, - { b => { b.MapPost("api/{id}", app => { }); }, c => { c.Request.Method = "POST"; } }, + { b => { b.MapMiddlewarePost("api/{id}", app => { }); }, c => { c.Request.Method = "POST"; } }, { b => { b.MapPut("api/{id}", NullHandler); }, c => { c.Request.Method = "PUT"; } }, - { b => { b.MapPut("api/{id}", app => { }); }, c => { c.Request.Method = "PUT"; } }, + { b => { b.MapMiddlewarePut("api/{id}", app => { }); }, c => { c.Request.Method = "PUT"; } }, { b => { b.MapVerb("PUT", "api/{id}", NullHandler); }, c => { c.Request.Method = "PUT"; } }, - { b => { b.MapVerb("PUT", "api/{id}", app => { }); }, c => { c.Request.Method = "PUT"; } }, + { b => { b.MapMiddlewareVerb("PUT", "api/{id}", app => { }); }, c => { c.Request.Method = "PUT"; } }, }; } } @@ -73,29 +73,29 @@ namespace Microsoft.AspNetCore.Routing return new TheoryData, Action>() { { b => { b.MapRoute("api/{id}/extra", NullHandler); }, null }, - { b => { b.MapRoute("api/{id}/extra", app => { }); }, null }, + { b => { b.MapMiddlewareRoute("api/{id}/extra", app => { }); }, null }, { b => { b.MapDelete("api/{id}", NullHandler); }, c => { c.Request.Method = "GET"; } }, - { b => { b.MapDelete("api/{id}", app => { }); }, c => { c.Request.Method = "PUT"; } }, + { b => { b.MapMiddlewareDelete("api/{id}", app => { }); }, c => { c.Request.Method = "PUT"; } }, { b => { b.MapDelete("api/{id}/extra", NullHandler); }, c => { c.Request.Method = "DELETE"; } }, - { b => { b.MapDelete("api/{id}/extra", app => { }); }, c => { c.Request.Method = "DELETE"; } }, + { b => { b.MapMiddlewareDelete("api/{id}/extra", app => { }); }, c => { c.Request.Method = "DELETE"; } }, { b => { b.MapGet("api/{id}", NullHandler); }, c => { c.Request.Method = "PUT"; } }, - { b => { b.MapGet("api/{id}", app => { }); }, c => { c.Request.Method = "POST"; } }, + { b => { b.MapMiddlewareGet("api/{id}", app => { }); }, c => { c.Request.Method = "POST"; } }, { b => { b.MapGet("api/{id}/extra", NullHandler); }, c => { c.Request.Method = "GET"; } }, - { b => { b.MapGet("api/{id}/extra", app => { }); }, c => { c.Request.Method = "GET"; } }, + { b => { b.MapMiddlewareGet("api/{id}/extra", app => { }); }, c => { c.Request.Method = "GET"; } }, { b => { b.MapPost("api/{id}", NullHandler); }, c => { c.Request.Method = "MEH"; } }, - { b => { b.MapPost("api/{id}", app => { }); }, c => { c.Request.Method = "DELETE"; } }, + { b => { b.MapMiddlewarePost("api/{id}", app => { }); }, c => { c.Request.Method = "DELETE"; } }, { b => { b.MapPost("api/{id}/extra", NullHandler); }, c => { c.Request.Method = "POST"; } }, - { b => { b.MapPost("api/{id}/extra", app => { }); }, c => { c.Request.Method = "POST"; } }, + { b => { b.MapMiddlewarePost("api/{id}/extra", app => { }); }, c => { c.Request.Method = "POST"; } }, { b => { b.MapPut("api/{id}", NullHandler); }, c => { c.Request.Method = "BLEH"; } }, - { b => { b.MapPut("api/{id}", app => { }); }, c => { c.Request.Method = "HEAD"; } }, + { b => { b.MapMiddlewarePut("api/{id}", app => { }); }, c => { c.Request.Method = "HEAD"; } }, { b => { b.MapPut("api/{id}/extra", NullHandler); }, c => { c.Request.Method = "PUT"; } }, - { b => { b.MapPut("api/{id}/extra", app => { }); }, c => { c.Request.Method = "PUT"; } }, + { b => { b.MapMiddlewarePut("api/{id}/extra", app => { }); }, c => { c.Request.Method = "PUT"; } }, { b => { b.MapVerb("PUT", "api/{id}", NullHandler); }, c => { c.Request.Method = "POST"; } }, - { b => { b.MapVerb("PUT", "api/{id}", app => { }); }, c => { c.Request.Method = "HEAD"; } }, + { b => { b.MapMiddlewareVerb("PUT", "api/{id}", app => { }); }, c => { c.Request.Method = "HEAD"; } }, { b => { b.MapVerb("PUT", "api/{id}/extra", NullHandler); }, c => { c.Request.Method = "PUT"; } }, - { b => { b.MapVerb("PUT", "api/{id}/extra", app => { }); }, c => { c.Request.Method = "PUT"; } }, + { b => { b.MapMiddlewareVerb("PUT", "api/{id}/extra", app => { }); }, c => { c.Request.Method = "PUT"; } }, }; } }