/// <summary> /// Sets the <see cref="HealthResponse.StatusCode"/> property of the <paramref name="response"/> /// according to the value of its <see cref="HealthResponse.Status"/> property and the values of /// the <see cref="IHealthCheckRunner.PassStatusCode"/>, <see cref="IHealthCheckRunner.WarnStatusCode"/>, /// and <see cref="IHealthCheckRunner.FailStatusCode"/> properties of the <paramref name="runner"/>. /// </summary> /// <param name="response">The <see cref="HealthResponse"/>.</param> /// <param name="runner">The <see cref="IHealthCheckRunner"/>.</param> /// <returns>The same <see cref="HealthResponse"/> object.</returns> public static HealthResponse SetStatusCode(this HealthResponse response, IHealthCheckRunner runner) { switch (response.Status) { case HealthStatus.Pass: response.StatusCode = runner.PassStatusCode; break; case HealthStatus.Warn: response.StatusCode = runner.WarnStatusCode; break; case HealthStatus.Fail: response.StatusCode = runner.FailStatusCode; break; } return(response); }
private HealthResponse TryCustomizeResponse(HealthResponse response) { try { ResponseCustomizer?.CustomizeResponse(response); } catch { } return(response); }