forked from kobake/AspNetCore.RouteAnalyzer
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
93554a1
commit d052d42
Showing
12 changed files
with
46 additions
and
59 deletions.
There are no files selected for viewing
9 changes: 5 additions & 4 deletions
9
AspNetCore.RouteAnalyzer.SampleWebProject/AspNetCore.RouteAnalyzer.SampleWebProject.csproj
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
6 changes: 1 addition & 5 deletions
6
AspNetCore.RouteAnalyzer.SampleWebProject/Controllers/HelloController.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
6 changes: 1 addition & 5 deletions
6
AspNetCore.RouteAnalyzer.SampleWebProject/Pages/About.cshtml.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
6 changes: 1 addition & 5 deletions
6
AspNetCore.RouteAnalyzer.SampleWebProject/Pages/Contact.cshtml.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
6 changes: 1 addition & 5 deletions
6
AspNetCore.RouteAnalyzer.SampleWebProject/Pages/Error.cshtml.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
7 changes: 1 addition & 6 deletions
7
AspNetCore.RouteAnalyzer.SampleWebProject/Pages/Index.cshtml.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
3 changes: 0 additions & 3 deletions
3
AspNetCore.RouteAnalyzer/Controllers/RouteAnalyzer_MainController.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,27 +1,47 @@ | ||
using AspNetCore.RouteAnalyzer.Inner; | ||
using Microsoft.AspNetCore.Builder; | ||
using Microsoft.AspNetCore.Http; | ||
using Microsoft.AspNetCore.Routing; | ||
using Microsoft.Extensions.DependencyInjection; | ||
using System; | ||
using System.Threading.Tasks; | ||
using System.Linq; | ||
using System.Diagnostics; | ||
|
||
namespace AspNetCore.RouteAnalyzer | ||
{ | ||
public static class RouteAnalyzerServiceCollectionExtensions | ||
{ | ||
public static IServiceCollection AddRouteAnalyzer(this IServiceCollection services) | ||
{ | ||
services.AddSingleton<IRouteAnalyzer, RouteAnalyzer.Inner.RouteAnalyzerImpl>(); | ||
services.AddSingleton<IRouteAnalyzer, RouteAnalyzerImpl>(); | ||
return services; | ||
} | ||
} | ||
|
||
public static class RouteAnalyzerRouteBuilderExtensions | ||
{ | ||
private static string AspNetCoreRouteAnalyzerRoute = "AspNetCore.RouteAnalyzer.Route"; | ||
public static string RouteAnalyzerUrlPath { get; private set; } = ""; | ||
|
||
public static IRouteBuilder MapRouteAnalyzer(this IRouteBuilder routes, string routeAnalyzerUrlPath) | ||
{ | ||
RouteAnalyzerUrlPath = routeAnalyzerUrlPath; | ||
routes.Routes.Add(new Router(routes.DefaultHandler, routeAnalyzerUrlPath)); | ||
return routes; | ||
public static IApplicationBuilder MapRouteAnalyzer(this IApplicationBuilder app, string routeAnalyzerUrlPath) | ||
{ | ||
var aspnetCorErouteHandler = new RouteHandler(context => | ||
{ | ||
return Task.Run(() => | ||
{ | ||
context.Response.Redirect("RouteAnalyzer_Main/ShowAllRoutes"); | ||
}); | ||
}); | ||
|
||
var routeBuilder = new RouteBuilder(app, aspnetCorErouteHandler); | ||
|
||
routeBuilder.MapRoute(AspNetCoreRouteAnalyzerRoute, routeAnalyzerUrlPath); | ||
|
||
var routes = routeBuilder.Build(); | ||
app.UseRouter(routes); | ||
|
||
return app; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters