Open
Description
I ended here looking for same thing as many, given .Net Core 3+ now uses Endpoint routing, this library is not needed anymore.
To save you some time, the following code will give you similar results:
public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
{
app.UseRouting();
app.UseAuthorization();
app.UseEndpoints(endpoints =>
{
endpoints.MapControllers();
endpoints.MapGet("/routes", request =>
{
request.Response.Headers.Add("content-type", "application/json");
var ep = endpoints.DataSources.First().Endpoints.Select(e => e as RouteEndpoint);
return request.Response.WriteAsync(
JsonSerializer.Serialize(
ep.Select(e => new
{
Method = ((HttpMethodMetadata)e.Metadata.First(m => m.GetType() == typeof(HttpMethodMetadata))).HttpMethods.First(),
Route = e.RoutePattern.RawText
})
)
);
});
});
}
Just tweak with data you need from the routes.
Metadata
Assignees
Labels
No labels