I added health checks to my ASP.NET Core 6 app, and everything is working properly.
I need to determine (programmatically, at runtime) all the health check routes, e.g. /healthz
, etc.
I tried:
// inject IEnumerable<EndpointDataSource>
// ...
var routes = _endpointDataSources.SelectMany(source => source.Endpoints);
But there's no way I can select the correct endpoints (using linq) without using a hack or magic string. The healthcheck endpoints have "Heath checks"
as their display names, but I assume that can change at any time, so it's not reliable.
How can I get those endpoints in a reliable way that won't break on the next update?