diff --git a/src/Mvc/samples/MvcSandbox/Startup.cs b/src/Mvc/samples/MvcSandbox/Startup.cs
index 58efaf78f0..c958e06b8e 100644
--- a/src/Mvc/samples/MvcSandbox/Startup.cs
+++ b/src/Mvc/samples/MvcSandbox/Startup.cs
@@ -32,7 +32,7 @@ namespace MvcSandbox
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
public void Configure(IApplicationBuilder app)
{
- app.UseEndpointRouting(builder =>
+ app.UseRouting(builder =>
{
builder.MapGet(
requestDelegate: WriteEndpoints,
diff --git a/src/Mvc/src/Microsoft.AspNetCore.Mvc.Core/Builder/MvcApplicationBuilderExtensions.cs b/src/Mvc/src/Microsoft.AspNetCore.Mvc.Core/Builder/MvcApplicationBuilderExtensions.cs
index 2d873de87c..6055f491a1 100644
--- a/src/Mvc/src/Microsoft.AspNetCore.Mvc.Core/Builder/MvcApplicationBuilderExtensions.cs
+++ b/src/Mvc/src/Microsoft.AspNetCore.Mvc.Core/Builder/MvcApplicationBuilderExtensions.cs
@@ -130,7 +130,7 @@ namespace Microsoft.AspNetCore.Builder
{
// Matching middleware has not been registered yet
// For back-compat register middleware so an endpoint is matched and then immediately used
- app.UseEndpointRouting(routerBuilder =>
+ app.UseRouting(routerBuilder =>
{
routerBuilder.DataSources.Add(mvcEndpointDataSource);
});
diff --git a/src/Routing/benchmarkapps/Benchmarks/StartupUsingEndpointRouting.cs b/src/Routing/benchmarkapps/Benchmarks/StartupUsingEndpointRouting.cs
index f6062f0531..beeef2bbad 100644
--- a/src/Routing/benchmarkapps/Benchmarks/StartupUsingEndpointRouting.cs
+++ b/src/Routing/benchmarkapps/Benchmarks/StartupUsingEndpointRouting.cs
@@ -21,7 +21,7 @@ namespace Benchmarks
public void Configure(IApplicationBuilder app)
{
- app.UseEndpointRouting(builder =>
+ app.UseRouting(builder =>
{
var endpointDataSource = new DefaultEndpointDataSource(new[]
{
diff --git a/src/Routing/build/dependencies.props b/src/Routing/build/dependencies.props
index 15eca73927..8b949c60f5 100644
--- a/src/Routing/build/dependencies.props
+++ b/src/Routing/build/dependencies.props
@@ -43,4 +43,4 @@
-
+
\ No newline at end of file
diff --git a/src/Routing/samples/RoutingSandbox/UseEndpointRoutingStartup.cs b/src/Routing/samples/RoutingSandbox/UseEndpointRoutingStartup.cs
index 88c48cf150..0f78d2f9e8 100644
--- a/src/Routing/samples/RoutingSandbox/UseEndpointRoutingStartup.cs
+++ b/src/Routing/samples/RoutingSandbox/UseEndpointRoutingStartup.cs
@@ -1,4 +1,4 @@
-// Copyright (c) .NET Foundation. All rights reserved.
+// 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;
@@ -31,7 +31,7 @@ namespace RoutingSandbox
public void Configure(IApplicationBuilder app)
{
- app.UseEndpointRouting(builder =>
+ app.UseRouting(builder =>
{
builder.MapHello("/helloworld", "World");
diff --git a/src/Routing/src/Microsoft.AspNetCore.Routing/Builder/EndpointRoutingApplicationBuilderExtensions.cs b/src/Routing/src/Microsoft.AspNetCore.Routing/Builder/EndpointRoutingApplicationBuilderExtensions.cs
index acdad5b2af..872236f22b 100644
--- a/src/Routing/src/Microsoft.AspNetCore.Routing/Builder/EndpointRoutingApplicationBuilderExtensions.cs
+++ b/src/Routing/src/Microsoft.AspNetCore.Routing/Builder/EndpointRoutingApplicationBuilderExtensions.cs
@@ -1,4 +1,4 @@
-// Copyright (c) .NET Foundation. All rights reserved.
+// 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;
@@ -14,8 +14,20 @@ namespace Microsoft.AspNetCore.Builder
// Property key is used by MVC package to check that routing is registered
private const string EndpointRoutingRegisteredKey = "__EndpointRoutingMiddlewareRegistered";
- public static IApplicationBuilder UseEndpointRouting(this IApplicationBuilder builder, Action configure)
+ ///
+ /// Adds a middleware to the specified
+ /// with the instances built from configured .
+ ///
+ /// The to add the middleware to.
+ /// An to configure the provided .
+ /// A reference to this instance after the operation has completed.
+ public static IApplicationBuilder UseRouting(this IApplicationBuilder builder, Action configure)
{
+ if (builder == null)
+ {
+ throw new ArgumentNullException(nameof(builder));
+ }
+
if (configure == null)
{
throw new ArgumentNullException(nameof(configure));
@@ -46,14 +58,24 @@ namespace Microsoft.AspNetCore.Builder
return builder.UseMiddleware(middlewareEndpointDataSource);
}
+ ///
+ /// Adds a middleware to the specified .
+ ///
+ /// The to add the middleware to.
+ /// A reference to this instance after the operation has completed.
public static IApplicationBuilder UseEndpoint(this IApplicationBuilder builder)
{
+ if (builder == null)
+ {
+ throw new ArgumentNullException(nameof(builder));
+ }
+
VerifyRoutingIsRegistered(builder);
if (!builder.Properties.TryGetValue(EndpointRoutingRegisteredKey, out _))
{
var message = $"{nameof(EndpointRoutingMiddleware)} must be added to the request execution pipeline before {nameof(EndpointMiddleware)}. " +
- $"Please add {nameof(EndpointRoutingMiddleware)} by calling '{nameof(IApplicationBuilder)}.{nameof(UseEndpointRouting)}' inside the call to 'Configure(...)' in the application startup code.";
+ $"Please add {nameof(EndpointRoutingMiddleware)} by calling '{nameof(IApplicationBuilder)}.{nameof(UseRouting)}' inside the call to 'Configure(...)' in the application startup code.";
throw new InvalidOperationException(message);
}
@@ -74,4 +96,4 @@ namespace Microsoft.AspNetCore.Builder
}
}
}
-}
\ No newline at end of file
+}
diff --git a/src/Routing/test/Microsoft.AspNetCore.Routing.Tests/Builder/EndpointRoutingApplicationBuilderExtensionsTest.cs b/src/Routing/test/Microsoft.AspNetCore.Routing.Tests/Builder/EndpointRoutingApplicationBuilderExtensionsTest.cs
index 7d0cb9a191..04b495b4f1 100644
--- a/src/Routing/test/Microsoft.AspNetCore.Routing.Tests/Builder/EndpointRoutingApplicationBuilderExtensionsTest.cs
+++ b/src/Routing/test/Microsoft.AspNetCore.Routing.Tests/Builder/EndpointRoutingApplicationBuilderExtensionsTest.cs
@@ -1,4 +1,4 @@
-// Copyright (c) .NET Foundation. All rights reserved.
+// 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;
@@ -21,13 +21,13 @@ namespace Microsoft.AspNetCore.Builder
public class EndpointRoutingApplicationBuilderExtensionsTest
{
[Fact]
- public void UseEndpointRouting_ServicesNotRegistered_Throws()
+ public void UseRouting_ServicesNotRegistered_Throws()
{
// Arrange
var app = new ApplicationBuilder(Mock.Of());
// Act
- var ex = Assert.Throws(() => app.UseEndpointRouting(builder => { }));
+ var ex = Assert.Throws(() => app.UseRouting(builder => { }));
// Assert
Assert.Equal(
@@ -55,14 +55,14 @@ namespace Microsoft.AspNetCore.Builder
}
[Fact]
- public async Task UseEndpointRouting_ServicesRegistered_NoMatch_DoesNotSetFeature()
+ public async Task UseRouting_ServicesRegistered_NoMatch_DoesNotSetFeature()
{
// Arrange
var services = CreateServices();
var app = new ApplicationBuilder(services);
- app.UseEndpointRouting(builder => { });
+ app.UseRouting(builder => { });
var appFunc = app.Build();
var httpContext = new DefaultHttpContext();
@@ -75,7 +75,7 @@ namespace Microsoft.AspNetCore.Builder
}
[Fact]
- public async Task UseEndpointRouting_ServicesRegistered_Match_DoesNotSetsFeature()
+ public async Task UseRouting_ServicesRegistered_Match_DoesNotSetsFeature()
{
// Arrange
var endpoint = new RouteEndpoint(
@@ -89,7 +89,7 @@ namespace Microsoft.AspNetCore.Builder
var app = new ApplicationBuilder(services);
- app.UseEndpointRouting(builder =>
+ app.UseRouting(builder =>
{
builder.DataSources.Add(new DefaultEndpointDataSource(endpoint));
});
@@ -133,7 +133,7 @@ namespace Microsoft.AspNetCore.Builder
var app = new ApplicationBuilder(services);
- app.UseEndpointRouting(builder => { });
+ app.UseRouting(builder => { });
app.UseEndpoint();
var appFunc = app.Build();
@@ -147,7 +147,7 @@ namespace Microsoft.AspNetCore.Builder
}
[Fact]
- public void UseEndpointRouting_CallWithBuilder_SetsEndpointDataSource()
+ public void UseRouting_CallWithBuilder_SetsEndpointDataSource()
{
// Arrange
var matcherEndpointDataSources = new List();
@@ -165,13 +165,13 @@ namespace Microsoft.AspNetCore.Builder
var app = new ApplicationBuilder(services);
// Act
- app.UseEndpointRouting(builder =>
+ app.UseRouting(builder =>
{
builder.Map("/1", "Test endpoint 1", d => null);
builder.Map("/2", "Test endpoint 2", d => null);
});
- app.UseEndpointRouting(builder =>
+ app.UseRouting(builder =>
{
builder.Map("/3", "Test endpoint 3", d => null);
builder.Map("/4", "Test endpoint 4", d => null);
diff --git a/src/Routing/test/WebSites/RoutingWebSite/UseEndpointRoutingStartup.cs b/src/Routing/test/WebSites/RoutingWebSite/UseEndpointRoutingStartup.cs
index 0ee48e5c83..c2f0578267 100644
--- a/src/Routing/test/WebSites/RoutingWebSite/UseEndpointRoutingStartup.cs
+++ b/src/Routing/test/WebSites/RoutingWebSite/UseEndpointRoutingStartup.cs
@@ -1,4 +1,4 @@
-// Copyright (c) .NET Foundation. All rights reserved.
+// 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;
@@ -35,7 +35,7 @@ namespace RoutingWebSite
public void Configure(IApplicationBuilder app)
{
- app.UseEndpointRouting(routes =>
+ app.UseRouting(routes =>
{
routes.MapHello("/helloworld", "World");
@@ -126,7 +126,7 @@ namespace RoutingWebSite
private void SetupBranch(IApplicationBuilder app, string name)
{
- app.UseEndpointRouting(routes =>
+ app.UseRouting(routes =>
{
routes.MapGet("api/get/{id}", (context) => context.Response.WriteAsync($"{name} - API Get {context.GetRouteData().Values["id"]}"));
});