aspnetcore/samples/RoutingSample/HttpContextRouteEndpoint.cs

32 lines
869 B
C#
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

// Copyright (c) Microsoft Open Technologies, Inc. All rights reserved. See License.txt in the project root for license information.
using System.Threading.Tasks;
using Microsoft.AspNet.Abstractions;
using Microsoft.AspNet.Routing;
namespace RoutingSample
{
public class HttpContextRouteEndpoint : IRouter
{
private readonly RequestDelegate _appFunc;
public HttpContextRouteEndpoint(RequestDelegate appFunc)
{
_appFunc = appFunc;
}
public async Task RouteAsync(RouteContext context)
{
await _appFunc(context.HttpContext);
context.IsHandled = true;
}
public string BindPath(BindPathContext context)
{
// We don't really care what the values look like.
context.IsBound = true;
return null;
}
}
}