Use an if statement
app.UseEndpoints(endpoints =>
{
var ep = endpoints.MapHealthChecks("/health");
if (UseHealtChecks)
ep.RequireAuthorization();
});
This browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
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();
});
Use an if statement
app.UseEndpoints(endpoints =>
{
var ep = endpoints.MapHealthChecks("/health");
if (UseHealtChecks)
ep.RequireAuthorization();
});