diff --git a/src/Microsoft.AspNet.Http.Core/Extensions/MapExtensions.cs b/src/Microsoft.AspNet.Http.Core/Extensions/MapExtensions.cs
index 5f71a1b792..3a53395fda 100644
--- a/src/Microsoft.AspNet.Http.Core/Extensions/MapExtensions.cs
+++ b/src/Microsoft.AspNet.Http.Core/Extensions/MapExtensions.cs
@@ -10,19 +10,6 @@ namespace Microsoft.AspNet.Builder
{
public static class MapExtensions
{
- ///
- /// If the request path starts with the given pathMatch, execute the app configured via configuration parameter instead of
- /// continuing to the next component in the pipeline.
- ///
- ///
- /// The path to match
- /// The branch to take for positive path matches
- ///
- public static IApplicationBuilder Map([NotNull] this IApplicationBuilder app, [NotNull] string pathMatch, [NotNull] Action configuration)
- {
- return Map(app, new PathString(pathMatch), configuration);
- }
-
///
/// If the request path starts with the given pathMatch, execute the app configured via configuration parameter instead of
/// continuing to the next component in the pipeline.
diff --git a/src/Microsoft.AspNet.Http.Core/Extensions/MapWhenExtensions.cs b/src/Microsoft.AspNet.Http.Core/Extensions/MapWhenExtensions.cs
index 117b8cacc1..30564a114b 100644
--- a/src/Microsoft.AspNet.Http.Core/Extensions/MapWhenExtensions.cs
+++ b/src/Microsoft.AspNet.Http.Core/Extensions/MapWhenExtensions.cs
@@ -5,12 +5,11 @@ using System;
using System.Threading.Tasks;
using Microsoft.AspNet.Http;
using Microsoft.AspNet.Builder.Extensions;
+using Microsoft.Framework.Internal;
namespace Microsoft.AspNet.Builder
{
- using Microsoft.Framework.Internal;
using Predicate = Func;
- using PredicateAsync = Func>;
///
/// Extension methods for the MapWhenMiddleware
@@ -39,28 +38,5 @@ namespace Microsoft.AspNet.Builder
};
return app.Use(next => new MapWhenMiddleware(next, options).Invoke);
}
-
- ///
- /// Branches the request pipeline based on the async result of the given predicate.
- ///
- ///
- /// Invoked asynchronously with the request environment to determine if the branch should be taken
- /// Configures a branch to take
- ///
- public static IApplicationBuilder MapWhenAsync([NotNull] this IApplicationBuilder app, [NotNull] PredicateAsync predicate, [NotNull] Action configuration)
- {
- // create branch
- var branchBuilder = app.New();
- configuration(branchBuilder);
- var branch = branchBuilder.Build();
-
- // put middleware in pipeline
- var options = new MapWhenOptions
- {
- PredicateAsync = predicate,
- Branch = branch,
- };
- return app.Use(next => new MapWhenMiddleware(next, options).Invoke);
- }
}
}
\ No newline at end of file
diff --git a/src/Microsoft.AspNet.Http.Core/Extensions/MapWhenMiddleware.cs b/src/Microsoft.AspNet.Http.Core/Extensions/MapWhenMiddleware.cs
index b4f5c78b0b..ab0e2d3dbf 100644
--- a/src/Microsoft.AspNet.Http.Core/Extensions/MapWhenMiddleware.cs
+++ b/src/Microsoft.AspNet.Http.Core/Extensions/MapWhenMiddleware.cs
@@ -20,27 +20,13 @@ namespace Microsoft.AspNet.Builder.Extensions
public async Task Invoke([NotNull] HttpContext context)
{
- if (_options.Predicate != null)
+ if (_options.Predicate(context))
{
- if (_options.Predicate(context))
- {
- await _options.Branch(context);
- }
- else
- {
- await _next(context);
- }
+ await _options.Branch(context);
}
else
{
- if (await _options.PredicateAsync(context))
- {
- await _options.Branch(context);
- }
- else
- {
- await _next(context);
- }
+ await _next(context);
}
}
}
diff --git a/src/Microsoft.AspNet.Http.Core/Extensions/MapWhenOptions.cs b/src/Microsoft.AspNet.Http.Core/Extensions/MapWhenOptions.cs
index c94b15f181..27a9d9b1be 100644
--- a/src/Microsoft.AspNet.Http.Core/Extensions/MapWhenOptions.cs
+++ b/src/Microsoft.AspNet.Http.Core/Extensions/MapWhenOptions.cs
@@ -17,11 +17,6 @@ namespace Microsoft.AspNet.Builder.Extensions
///
public Func Predicate { get; set; }
- ///
- /// The async user callback that determines if the branch should be taken
- ///
- public Func> PredicateAsync { get; set; }
-
///
/// The branch taken for a positive match
///
diff --git a/src/Microsoft.AspNet.Http.Core/Extensions/RunExtensions.cs b/src/Microsoft.AspNet.Http.Core/Extensions/RunExtensions.cs
index c0cb5af259..ad103c3d1e 100644
--- a/src/Microsoft.AspNet.Http.Core/Extensions/RunExtensions.cs
+++ b/src/Microsoft.AspNet.Http.Core/Extensions/RunExtensions.cs
@@ -14,25 +14,5 @@ namespace Microsoft.AspNet.Builder
{
app.Use(_ => handler);
}
-
- public static void Run(this IApplicationBuilder app, Func handler)
- {
- app.Use((ctx, _, s1) => handler(ctx, s1));
- }
-
- public static void Run(this IApplicationBuilder app, Func handler)
- {
- app.Use((ctx, _, s1, s2) => handler(ctx, s1, s2));
- }
-
- public static void Run(this IApplicationBuilder app, Func handler)
- {
- app.Use((ctx, _, s1, s2, s3) => handler(ctx, s1, s2, s3));
- }
-
- public static void Run(this IApplicationBuilder app, Func handler)
- {
- app.Use((ctx, _, s1, s2, s3, s4) => handler(ctx, s1, s2, s3, s4));
- }
}
}
\ No newline at end of file
diff --git a/test/Microsoft.AspNet.Http.Core.Tests/MapPathMiddlewareTests.cs b/test/Microsoft.AspNet.Http.Core.Tests/MapPathMiddlewareTests.cs
index e0d7b30689..071e8fbdaf 100644
--- a/test/Microsoft.AspNet.Http.Core.Tests/MapPathMiddlewareTests.cs
+++ b/test/Microsoft.AspNet.Http.Core.Tests/MapPathMiddlewareTests.cs
@@ -60,7 +60,7 @@ namespace Microsoft.AspNet.Builder.Extensions
{
HttpContext context = CreateRequest(basePath, requestPath);
var builder = new ApplicationBuilder(serviceProvider: null);
- builder.Map(matchPath, UseSuccess);
+ builder.Map(new PathString(matchPath), UseSuccess);
var app = builder.Build();
app.Invoke(context).Wait();
@@ -81,7 +81,7 @@ namespace Microsoft.AspNet.Builder.Extensions
{
HttpContext context = CreateRequest(basePath, requestPath);
var builder = new ApplicationBuilder(serviceProvider: null);
- builder.Map(matchPath, subBuilder => subBuilder.Run(Success));
+ builder.Map(new PathString(matchPath), subBuilder => subBuilder.Run(Success));
var app = builder.Build();
app.Invoke(context).Wait();
@@ -96,7 +96,7 @@ namespace Microsoft.AspNet.Builder.Extensions
[InlineData("/foo/cho/")]
public void MatchPathWithTrailingSlashThrowsException(string matchPath)
{
- Should.Throw(() => new ApplicationBuilder(serviceProvider: null).Map(matchPath, map => { }).Build());
+ Should.Throw(() => new ApplicationBuilder(serviceProvider: null).Map(new PathString(matchPath), map => { }).Build());
}
[Theory]
@@ -111,7 +111,7 @@ namespace Microsoft.AspNet.Builder.Extensions
{
HttpContext context = CreateRequest(basePath, requestPath);
var builder = new ApplicationBuilder(serviceProvider: null);
- builder.Map(matchPath, UseNotImplemented);
+ builder.Map(new PathString(matchPath), UseNotImplemented);
builder.Run(Success);
var app = builder.Build();
app.Invoke(context).Wait();
@@ -133,7 +133,7 @@ namespace Microsoft.AspNet.Builder.Extensions
{
HttpContext context = CreateRequest(basePath, requestPath);
var builder = new ApplicationBuilder(serviceProvider: null);
- builder.Map(matchPath, UseNotImplemented);
+ builder.Map(new PathString(matchPath), UseNotImplemented);
builder.Run(Success);
var app = builder.Build();
app.Invoke(context).Wait();
@@ -147,12 +147,12 @@ namespace Microsoft.AspNet.Builder.Extensions
public void ChainedRoutes_Success()
{
var builder = new ApplicationBuilder(serviceProvider: null);
- builder.Map("/route1", map =>
+ builder.Map(new PathString("/route1"), map =>
{
- map.Map((string)"/subroute1", UseSuccess);
+ map.Map(new PathString("/subroute1"), UseSuccess);
map.Run(NotImplemented);
});
- builder.Map("/route2/subroute2", UseSuccess);
+ builder.Map(new PathString("/route2/subroute2"), UseSuccess);
var app = builder.Build();
HttpContext context = CreateRequest(string.Empty, "/route1");
diff --git a/test/Microsoft.AspNet.Http.Core.Tests/MapPredicateMiddlewareTests.cs b/test/Microsoft.AspNet.Http.Core.Tests/MapPredicateMiddlewareTests.cs
index fef12361fd..29b6eac3ff 100644
--- a/test/Microsoft.AspNet.Http.Core.Tests/MapPredicateMiddlewareTests.cs
+++ b/test/Microsoft.AspNet.Http.Core.Tests/MapPredicateMiddlewareTests.cs
@@ -16,7 +16,6 @@ namespace Microsoft.AspNet.Builder.Extensions
public class MapPredicateMiddlewareTests
{
private static readonly Predicate NotImplementedPredicate = new Predicate(envionment => { throw new NotImplementedException(); });
- private static readonly PredicateAsync NotImplementedPredicateAsync = new PredicateAsync(envionment => { throw new NotImplementedException(); });
private static Task Success(HttpContext context)
{
@@ -49,16 +48,6 @@ namespace Microsoft.AspNet.Builder.Extensions
return false;
}
- private Task TruePredicateAsync(HttpContext context)
- {
- return Task.FromResult(true);
- }
-
- private Task FalsePredicateAsync(HttpContext context)
- {
- return Task.FromResult(false);
- }
-
[Fact]
public void NullArguments_ArgumentNullException()
{
@@ -113,31 +102,6 @@ namespace Microsoft.AspNet.Builder.Extensions
Assert.Equal(200, context.Response.StatusCode);
}
- [Fact]
- public void PredicateAsyncTrueAction_BranchTaken()
- {
- HttpContext context = CreateRequest();
- var builder = new ApplicationBuilder(serviceProvider: null);
- builder.MapWhenAsync(TruePredicateAsync, UseSuccess);
- var app = builder.Build();
- app.Invoke(context).Wait();
-
- Assert.Equal(200, context.Response.StatusCode);
- }
-
- [Fact]
- public void PredicateAsyncFalseAction_PassThrough()
- {
- HttpContext context = CreateRequest();
- var builder = new ApplicationBuilder(serviceProvider: null);
- builder.MapWhenAsync(FalsePredicateAsync, UseNotImplemented);
- builder.Run(Success);
- var app = builder.Build();
- app.Invoke(context).Wait();
-
- Assert.Equal(200, context.Response.StatusCode);
- }
-
[Fact]
public void ChainedPredicates_Success()
{
@@ -155,23 +119,6 @@ namespace Microsoft.AspNet.Builder.Extensions
Assert.Equal(200, context.Response.StatusCode);
}
- [Fact]
- public void ChainedPredicatesAsync_Success()
- {
- var builder = new ApplicationBuilder(serviceProvider: null);
- builder.MapWhenAsync(TruePredicateAsync, map1 =>
- {
- map1.MapWhenAsync((PredicateAsync)FalsePredicateAsync, UseNotImplemented);
- map1.MapWhenAsync((PredicateAsync)TruePredicateAsync, map2 => map2.MapWhenAsync((PredicateAsync)TruePredicateAsync, UseSuccess));
- map1.Run(NotImplemented);
- });
- var app = builder.Build();
-
- HttpContext context = CreateRequest();
- app.Invoke(context).Wait();
- Assert.Equal(200, context.Response.StatusCode);
- }
-
private HttpContext CreateRequest()
{
HttpContext context = new DefaultHttpContext();