For health check I am using UseHealthChecks middleware extension where I am setting path argument to /hc.
How can add or remove authorization here based on config?
I want to achieve similar to below code with UseHealthChecks where I can add or remove RequireAuthorization based on condition.
app.UseEndpoints(endpoints =>
{
endpoints.MapHealthChecks("/health").RequireAuthorization();
});