Skip to content

Instantly share code, notes, and snippets.

@mr5z
Created May 10, 2021 08:30
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mr5z/569f4009bf3f900023b64007ed3f81a5 to your computer and use it in GitHub Desktop.
Save mr5z/569f4009bf3f900023b64007ed3f81a5 to your computer and use it in GitHub Desktop.
GET api/monitor
[Route("api/[controller]")]
[ApiController]
public class MonitorController : Controller
{
private readonly IActionDescriptorCollectionProvider _provider;
public MonitorController(IActionDescriptorCollectionProvider provider)
{
_provider = provider;
}
[HttpGet]
public IActionResult GetRoutes()
{
var routes = _provider.ActionDescriptors.Items.Select(x => new {
Action = x.RouteValues["Action"],
Controller = x.RouteValues["Controller"],
Name = x.AttributeRouteInfo?.Name,
Template = x.AttributeRouteInfo?.Template
}).ToList();
return Ok(routes);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment