Removing OwinRouteEndpoint

This commit is contained in:
Ryan Nowak 2014-02-04 16:24:17 -08:00
parent cd0b684094
commit 856c09ae10
2 changed files with 1 additions and 49 deletions

View File

@ -1,32 +0,0 @@
// Copyright (c) Microsoft Open Technologies, Inc. All rights reserved. See License.txt in the project root for license information.
#if NET45
using System;
using System.Collections.Generic;
using System.Threading.Tasks;
using Microsoft.AspNet.Abstractions;
using Microsoft.AspNet.PipelineCore.Owin;
using Microsoft.AspNet.Routing;
namespace RoutingSample
{
internal class OwinRouteEndpoint : IRouteEndpoint
{
private readonly Func<IDictionary<string, object>, Task> _appFunc;
public OwinRouteEndpoint(Func<IDictionary<string, object>, Task> appFunc)
{
_appFunc = appFunc;
}
public async Task<bool> Send(HttpContext context)
{
var owinContext = context.GetFeature<ICanHasOwinEnvironment>().Environment;
await _appFunc(owinContext);
return true;
}
}
}
#endif

View File

@ -2,17 +2,9 @@
#if NET45
using System.Collections.Generic;
using System.IO;
using System.Text;
using System.Threading.Tasks;
using Microsoft.AspNet.Abstractions;
using Microsoft.AspNet.Routing.Owin;
using Owin;
using Microsoft.AspNet.PipelineCore.Owin;
using Microsoft.AspNet.Routing;
using System;
using Microsoft.AspNet.Abstractions;
namespace RoutingSample
{
@ -29,7 +21,7 @@ namespace RoutingSample
{
var routes = builder.UseRouter();
var endpoint1 = new OwinRouteEndpoint(async (context) => await WriteToBodyAsync(context, "match1"));
var endpoint1 = new HttpContextRouteEndpoint(async (context) => await context.Response.WriteAsync("match1"));
var endpoint2 = new HttpContextRouteEndpoint(async (context) => await context.Response.WriteAsync("Hello, World!"));
routes.Add(new PrefixRoute(endpoint1, "api/store"));
@ -37,14 +29,6 @@ namespace RoutingSample
routes.Add(new PrefixRoute(endpoint2, "hello/world"));
routes.Add(new PrefixRoute(endpoint1, ""));
}
private static async Task WriteToBodyAsync(IDictionary<string, object> context, string text)
{
var stream = (Stream)context["owin.ResponseBody"];
byte[] bytes = Encoding.UTF8.GetBytes(text);
await stream.WriteAsync(bytes, 0, bytes.Length);
}
}
}