You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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.
The text was updated successfully, but these errors were encountered:
guibirow
changed the title
Snipped to use with .Net Core 3.x using Endpoint routing
Snippet to use with .Net Core 3.x using Endpoint routing
Jun 3, 2020
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:
Just tweak with data you need from the routes.
The text was updated successfully, but these errors were encountered: