aspnetcore/samples/RoutingSample.Web/Startup.cs

23 lines
810 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.

using Microsoft.AspNet.Abstractions;
using Microsoft.AspNet.Routing;
namespace RoutingSample.Web
{
public class Startup
{
public void Configuration(IBuilder builder)
{
var routes = builder.UseRouter();
var endpoint1 = new HttpContextRouteEndpoint(async (context) => await context.Response.WriteAsync("match1"));
var endpoint2 = new HttpContextRouteEndpoint(async (context) => await context.Response.WriteAsync("Hello, World!"));
routes.DefaultHandler = endpoint1;
routes.AddPrefixRoute("api/store");
routes.MapRoute("api/{controller}/{*extra}", new { controller = "Store" });
routes.AddPrefixRoute("hello/world", endpoint2);
routes.AddPrefixRoute("", endpoint2);
}
}
}